Hello all,
Need help with the below code. I want to run defrag.exe from within a script then have the script pause until defrag.exe finishes, it should then resume execution. Problem is that defrag.exe spawns dfrgntfs.exe, how do I pass this to the script? It's not pausing!
Thanks for the help!
Sip
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run "defrag.exe c: -a",True
strComputer = ""
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Need help with the below code. I want to run defrag.exe from within a script then have the script pause until defrag.exe finishes, it should then resume execution. Problem is that defrag.exe spawns dfrgntfs.exe, how do I pass this to the script? It's not pausing!
Thanks for the help!
Sip
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run "defrag.exe c: -a",True
strComputer = ""
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()