Running Defrag.exe

(imported topic written by SystemAdmin)

  • I have a script that runs against WinXP machines and I am trying to get it to run against Win7 machines but I am having issues. Here is the script:

delete “c:\defrag_status.txt”

runhidden cmd /C “{pathname of system folder}\defrag.exe” c: -f 1> c:\defrag_status.txt 2>&1

  • I get the following result on Win7 machines:

‘c:\windows\system32\defrag.exe’ is not recognized as an internal or external command, operable program or batch file.

  • I ran the following command to see if the system session that Bigfix starts can see any defrag.exe on the system using this script:

runhidden cmd /C dir /s c:*defrag.exe 1> c:\defrag_status7.txt 2>&1

  • I only find defrag.exe in the following directory:

c:\Windows\winsxs\amd64_microsoft-windows-defrag-cmdline_31bf3856ad364e35_6.1.7600.16385_none_2370c162e00680c3

  • I have also tried this without the path, with no success.

  • I have confirmed that defrag.exe exists on the system as I can run the same command as administrator or with using psexec -s (system account) to run the defrag.exe command.

  • I assume this has to do with Win7 file redirection. Do you know how I can call defrag.exe through actionscript on Win7?

(imported comment written by Lee Wei)

The TEM Agent is a 32-bit program. It will only see 32-bit pathways by default. But we can use the “x64” inspector.

q: exists file "defrag.exe" of system folder
A: False
 
q: exists file "defrag.exe" of system x64 folder
A: True
 
q: exists file "c:\windows\system32\defrag.exe"
A: False
 
q: exists x64 file "c:\windows\system32\defrag.exe"
A: True

So in your Relevance substitution for the ActionScript, we can use

if (x64 of operating system) then () else ()

Lee Wei

(imported comment written by SystemAdmin)

Hello Lee, I hope all is well.

The relevance part I have down. The problem is trying to use relevance to substitute the path and run the defrag.exe program. Even without the substitution I cannot run c:\windows\system32\defrag.exe in Bigfix action script. Do you know how I can accomplish this?

For example:

This is what I am trying to run:

delete “c:\defrag_status.txt”

runhidden cmd /C “c:\windows\system32\defrag.exe” c: -f > c:\defrag_status.txt

(imported comment written by SystemAdmin)

You could also begin your actionscript with the following:

action uses wow64 redirection false

(imported comment written by SystemAdmin)

perfect, that works! Thank you!!!