Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


[RESOLVED]Failed Shutdown

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,26105
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> [RESOLVED]Failed Shutdown
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 [RESOLVED]Failed Shutdown - 9/20/2005 4:59:22 AM   
  JimmyFo

 

Posts: 5
Score: 0
Joined: 9/20/2005
Status: offline
Hi, I am looking to write a script that can be called from a seperate program and shutdown the computer after displaying a warning.


      

This doesn't work properly though. Ideas?

If I click cancel, I would like it to terminate the VBScript so that reboot does not occur. Also, could I replace reboot with shutdown? When I try this, my system hangs.

Thanks,
James

< Message edited by JimmyFo -- 9/20/2005 6:39:27 AM >
 
 
Post #: 1
 
 RE: Failed Shutdown - 9/20/2005 5:44:37 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
You have to capture the cancel button.  In your script, you click Cancel and since you don't check for it, it will go on to the next part of the script.  Try something like this.

ret = WshShell.Popup(strText,IntSecToWait,strTitle,intType)
If ret = 2 then '2=cancel button'  Taken from WSH Docs.
  Msgbox " Reboot stopped"
End if

Do reboot here.


As to your shutdown, doing a quick search in Script Center, there seems to be a .Win32ShutDown(1).  Try


objOperatingSystem.Win32Shutdown(1)

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to JimmyFo)
 
 
Post #: 2
 
 RE: Failed Shutdown - 9/20/2005 5:45:56 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
 Here's a script that will shutdown and power off (if the computer supports) Win 2000:


Const SHUTDOWN = 8
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(SHUTDOWN)
Next


Use SHUTDOWN = 1 to shutdown without powering off.

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to mbouchard)
 
 
Post #: 3
 
 RE: Failed Shutdown - 9/20/2005 6:39:29 AM   
  JimmyFo

 

Posts: 5
Score: 0
Joined: 9/20/2005
Status: offline
Thanks guys, works great! :)

(in reply to Snipah)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> [RESOLVED]Failed Shutdown Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts