Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shutdown PC using SAS 1

Status
Not open for further replies.

tubbsy123

Programmer
Dec 2, 2004
19
AU
Hi,

I am having trouble writing some code that shutsdown my PC after completing an automated piece of code.

The idea is that once the code has finished the PC shuts istelf down.

Does anybody know how to do this.

Any help would be greatly received.

Regards

Tubbsy
 
I think you would have to use SAS to execute a .vbs file to shutdown the PC.

Here is a quick attempt to show how it could be done:

Code:
data _null_;
	file "c:\temp\Shutdown.vbs";
put 'Sub ShutDown';
put 'nLogOff=0';
put 'nReboot=2' ;
put 'nForceLogOff=4';
put 'nForceReboot=6'; 
put 'nPowerDown=8'; 
put 'nForcePowerDown=12'; 
put 'Set oOS = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")'; 
put 'For Each oOperatingSystem in oOS';
put 'oOperatingSystem.Win32Shutdown(nForcePowerDown)'; 
put 'Next'; 
put 'End sub'; 
put 'ShutDown'; 
run;

*X line to run vbs code;
x '"c:\temp\Shutdown.vbs"';

I just did a google search for "vbs shutdown pc" to find the vbs code.(I'm a SAS guy, not a vbs guy)
I'm assuming you'd also want to put a command to exit out of the SAS application prior to shutdown.

Good luck!
~Dave
 
You should be able to use the shutdown dos command (not tested for obvious reasons).

Code:
x 'shutdown' ;

For a list of options available for this command type:
Code:
shutdown /?
at the command line.

 
Thanks dblan this code works really well.

kdt82 using the x command and 'shutdown' doesn't seem to work. Thanks for the post though.

Regards

Tubbsy123
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top