Shutdown with screen locked

A

Angelo Campitelli

Im using the following script to reboot my machine... however if i have
locked the screen with

rundll32.exe user32.dll,LockWorkStation

the script doesnt shutdown the machine. It just kills the running
processes.... Any ideahow i can get it to shutdown the machine with the
screen locked.


Set OpSysSet =
GetObject("winmgmts:{impersonationLevel=impersonate,(RemoteShutdown)}//alexn-
pc ").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Reboot()
Next
 
T

Torgeir Bakken \(MVP\)

Angelo said:
Im using the following script to reboot my machine... however if i have
locked the screen with

rundll32.exe user32.dll,LockWorkStation

the script doesnt shutdown the machine. It just kills the running
processes.... Any ideahow i can get it to shutdown the machine with the
screen locked.


Set OpSysSet =
GetObject("winmgmts:{impersonationLevel=impersonate,(RemoteShutdown)}//alexn-
pc ").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Reboot()
Next
Hi

See if using the Win32Shutdown method with forced reboot parameter
works better:

'--------------------8<----------------------
' define the constants for more understandable code
Const EWX_REBOOT = 2
Const EWX_FORCE = 4

For Each OpSys In OpSysSet
OpSys.Win32Shutdown EWX_REBOOT + EWX_FORCE
Next
'--------------------8<----------------------


If that doesn't help, take the debug privilege (in addition to
the forced reboot).

Change (RemoteShutdown) to (RemoteShutdown,Debug)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top