win32shutdown 1 + 4 can't bring this Win2K down 
Author Message
 win32shutdown 1 + 4 can't bring this Win2K down

I targeted a Win2KSP3 Server box and the script below worked great.

I targeted a Win2K SP2 Prof and the script below doesn't shutdown the box as
expected.
Could  the lack of Win2KSP3, or another issue that doesn't allow the script
below to work on the Win2KProf machine ?

Const EWX_FORCE = 4
Const EWX_POWEROFF = 8

MsgBox "This Script Will Reboot A Remote Machine.", 64 , "Fun Scripting"

MsgBox "You Must Have Administrator Rights On The Machine You Want To
Reboot.", 64 , "Fun Scripting"

svrInput = InputBox ("Enter The Machine Name You Want To ReBoot." & vbCRLF &
_
vbCRLF & Space(2) & "\\ Marks Before The Name Are Not Needed." & vbCRLF & _
vbCRLF & Space(6) & "Just Enter The Machine Name." , "Fun Scripting")

If svrInput = "" Then
  WScript.Echo "You Entered Nothing, Script Has Terminated! Try Again!"
  WScript.Quit
End If

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & svrInput &
"\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from
Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
     ObjOperatingSystem.win32shutdown EWx_POWEROFF + EWX_SHUTDOWN
Next



Sat, 16 Jul 2005 15:05:39 GMT  
 win32shutdown 1 + 4 can't bring this Win2K down

Quote:

> I targeted a Win2KSP3 Server box and the script below worked great.

> I targeted a Win2K SP2 Prof and the script below doesn't shutdown the box as
> expected.
> Could  the lack of Win2KSP3, or another issue that doesn't allow the script
> below to work on the Win2KProf machine ?

> Const EWX_FORCE = 4
> Const EWX_POWEROFF = 8
> (snip)

> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,(Shutdown)}!\\" & svrInput &
> "\root\cimv2")
> Set colOperatingSystems = objWMIService.ExecQuery ("Select * from
> Win32_OperatingSystem")
> For Each objOperatingSystem in colOperatingSystems
>      ObjOperatingSystem.win32shutdown EWx_POWEROFF + EWX_SHUTDOWN
> Next

Hi

EWx_POWEROFF and EWX_SHUTDOWN isn't a "legal" combination I think (but I see
that EWX_SHUTDOWN is not defined in your script, so it should not harm anything
I guess).

Try to add the Force flag instead. This flag is needed if e.g. a password
protected screensaver is active on the computer you want to shut down/restart.

ObjOperatingSystem.win32shutdown EWX_POWEROFF + EWX_FORCE

Also note that not all computers supports poweroff (could be an issue on older
computers at least), so if EWX_POWEROFF + EWX_FORCE doesn't work, try

ObjOperatingSystem.win32shutdown EWX_SHUTDOWN + EWX_FORCE

and add this one to your const list:

Const EWX_SHUTDOWN = 1

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Sat, 16 Jul 2005 15:46:59 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. This brings down IE, FrontPage, Script Editor ?????

2. Bringing Exchange down and up

3. Harmless text file brings down whole World

4. Script to shut down Win2K service?

5. shut down, win2k and vbscript

6. 'Canned' data in VB program

7. class doesn't support automation error Win2k/ie5.5/jscript5.6

8. Understanding Win2K's PS driver output

9. Can't Launch Office 2000 shortcuts using RUN method in Win2k

10. Change NIC Card's IP Address in Win2k

11. Change NIC Card's IP Address in Win2k

12. Check Win2K Disk Quota's?

 

 
Powered by phpBB® Forum Software