I'm trying to develop a vbscript that will allow me to shutdown a PC
(running Windows XP Pro) on a Windows 2003 network. I would like to
implement this a policy for my laptop computer users. This policy
will check to see if the computer's virus defintions are upto date.
If not the laptop will be shutdown before the user can logon to our
network.
The script needs to be run when the PC first starts up, BUT before the
user logs on. I know where to set up the script (as part Local
Computer Policy -> Computer Configuration ->Windows Settings ->
Scripts (Startup/Shutdown) -> Startup). I've tried everything from
executing the windows shutdown command from a vbscript (shutdown.exe
-s -t 00) to various vbscript code including:
Const SHUTDOWN = 1
strComputer = "."
Set objWMIService = GetObject("winmgmts: {(Shutdown)}" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(SHUTDOWN)
Next
The problem is that the PC will not shut down. After the startup code
is excuted, I see the logon prompt. Which means I'm past the startup
script and into the user logon part of the entire authentication
process.
I know the shutdown code works. I've tested it while I've been logged
on. It shuts down the machine every time. I know that the shutdown
code was executed. I saw a test message. that I put after the
shutdown code. Yet the PC will not shutdown!
I think the problem is that I have the wrong permissions, but I'm
unsure how to fix the problem.
Any thoughts and script samples would be greatly appreciated.
Thanks in advance. ...Gary White