Hi Guys
I have a requirement to remove some registry entries, modify some files and
remove a service on a range of computers. I have decided to implement this in
a computer startup script delivered via a GPO.
My code works under a logged in user's context but doesn't seem to work in
the security context of a startup script (SYSTEM?).
The code executes and doesn't raise any errors but doesn't perform the last
step which is the reboot. I have turned on some additional event audfit
logging but do not see any failures. Anyone got any ideas?
The reboot function is below and I have removed out the error handling and
logging bits for clarity.
Function ShutDown()
sComputerName = "."
Set oWMI = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,(Shutdown, RemoteShutdown)}!\\" &
sComputerName & "\root\cimv2")
Set colOperatingSystems = oWMI.ExecQuery("Select * from
Win32_OperatingSystem")
For Each obj in colOperatingSystems
obj.Win32Shutdown(6)
Next
End Function