Tuesday, November 16, 2010

How can I shut down my PC using a VB Script?

Hi all,



I would like a VB script which, when opened, shuts down the PC. I will admit that I know nothing about VB and do not have the time to learn. I need this for an outside application... I don't think it should be difficult for an experienced programmer. Thanks!How can I shut down my PC using a VB Script?
The above answer is a good answer for doing it in VB Script (right out of XP).



But, if the script is going to be invoked from a command script, on XP, like a .bat or .cmd, check out the ';shutdown'; command line command.How can I shut down my PC using a VB Script?
hey you dont need that at all,just do the normal way
strComputer = ';.';

Set objWMIService = GetObject(';winmgmts:'; _

%26amp; ';{impersonationLevel=impersonate}!\\'; _

%26amp; strComputer %26amp; ';\root\cimv2';)

Set colOperatingSystems = objWMIService.ExecQuery _

(';Select * from Win32_OperatingSystem';)

For Each objOperatingSystem in colOperatingSystems

objOperatingSystem.Shutdown

Next

No comments:

Post a Comment