How to shutdown host used by script? 
Author Message
 How to shutdown host used by script?

Hi, I am finding a script to shutdown host(including power). Would you give
a good stuff? Thanks!


Fri, 27 May 2005 16:45:16 GMT  
 How to shutdown host used by script?
Check out the shutdown.vbs script from the Windows 2000 Resource Kit.  It
should do everything you need it to.

CJ M


Quote:
> Hi, I am finding a script to shutdown host(including power). Would you
give
> a good stuff? Thanks!



Fri, 27 May 2005 23:44:37 GMT  
 How to shutdown host used by script?


Quote:
> Hi, I am finding a script to shutdown host(including power). Would you
give
> a good stuff? Thanks!



Sat, 28 May 2005 00:25:23 GMT  
 How to shutdown host used by script?
Hi Terry,

Many of the shutdown routines are Windows version
specific.  You didn't specify OS.  If you can add an
ActiveX component, AutoItX will add scripting
shutdown method that works on all OS's.  In addition,
there are third party freeware utilities that can be run
from script to shut down any Windows OS.

AutoItX:
http://www.hiddensoft.com/AutoIt/index.html

Regards,
Joe Earnest


Quote:
> Hi, I am finding a script to shutdown host(including power). Would you
give
> a good stuff? Thanks!



Sat, 28 May 2005 00:33:04 GMT  
 How to shutdown host used by script?
oops ...  too many clicks.  sorry.

Joe Earnest



Sat, 28 May 2005 00:48:44 GMT  
 How to shutdown host used by script?

Quote:

> Hi, I am finding a script to shutdown host(including power). Would you give
> a good stuff? Thanks!

Hi

Free command line based shutdown/poweroff utilities (from VBScript you can use
the Run method to execute them):

Wizmo
http://grc.com/wizmo/wizmo.htm

Budja shutdown
http://www.budja.com/shutdown/

Search for poweroff at http://download.com.com/
Poweroff 3.0 is one of the possibilities (it has it's own scheduler as well)

Using VBScript/WMI works very well also. WMI comes default with WinME, Win2k and
WinXP. Put the following code into a file called e.g. shutdwn.vbs, run it with
wscript.exe <path-to-vbs-file>:

' Use "PowerOff" for a poweroff
' Use "PowerOff_Force" for a forced poweroff
' Use "Shutdown" for a shutdown
' Use "Shutdown_Force" for a forced shutdown
' Use "Reboot" for a reboot
' Use "Reboot_Force" for a forced reboot
' use "." for local computer

ShutDown ".", "PowerOff"

Sub ShutDown(sNode, sAction)

  Const EWX_LOGOFF = 0
  Const EWX_SHUTDOWN = 1
  Const EWX_REBOOT = 2
  Const EWX_FORCE = 4
  Const EWX_POWEROFF = 8

  Set oWMI = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate,(Shutdown)}!\\" _
     & sNode & "\root\cimv2")

  Set colOperatingSystems = oWMI.ExecQuery _
     ("Select * from Win32_OperatingSystem")
  For Each obj in colOperatingSystems
    Set oOS = obj :  Exit For
  Next

  sAction = LCase(sAction)

  Select Case sAction
    Case "logoff"
      iCmd = EWX_LOGOFF
    Case "logoff_force"
      iCmd = EWX_LOGOFF + EWX_FORCE
    Case "shutdown"
      iCmd = EWX_SHUTDOWN
    Case "shutdown_force"
      iCmd = EWX_SHUTDOWN + EWX_FORCE
    Case "reboot"
      iCmd = EWX_REBOOT
    Case "reboot_force"
      iCmd = EWX_REBOOT + EWX_FORCE
    Case "poweroff"
      iCmd = EWX_POWEROFF
    Case "poweroff_force"
      iCmd = EWX_POWEROFF + EWX_FORCE
    Case Else
      ' Default value
      iCmd = EWX_POWEROFF
  End Select

  oOS.Win32shutdown iCmd
End Sub

--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway



Sun, 29 May 2005 02:43:15 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Windows Scripting Host Shutdown Detection

2. Call Script subroutine from the Host using Script Control

3. Research: Windows Script Host or Windows Scripting Host

4. Schedulling using Windows Script Host WSH and vbs

5. Using Scripting host temporarly

6. Using Script Host in a COM Object

7. Host (server) side scripting: generating a page using data

8. Starting a c#.net window app (no UI) using window script host shell

9. Microsoft Windows Script Host 2.0 by Using Javascripts

10. Using Scripting Host in my own apps

11. Shutdown windows using vbscript

12. Shutdown using WSH??

 

 
Powered by phpBB® Forum Software