I have been trying to work on creating a script that will shut down a
computer when ran. Only problem is i managed to code it in VBA.
Take into account i have never learned VBS before and figured they
would be similar, unfortunately running the script directly doesnt
work...however if i copy the code into Excels macro section...the
computer shuts down correctly.
I would be appreciative if someone could help me recode this to run
through VBS
The coding is as follows:
Sub Shutdown()
Dim osObj, osColl
Const nForcePowerDown = 12
Set osColl = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select *
from Win32_OperatingSystem")
For Each osObj In osColl
osObj.Win32Shutdown (nForcePowerDown)
Next
End Sub