Scripts needed for WinXP shutdown.. 
Author Message
 Scripts needed for WinXP shutdown..

Dear all,

I'm looking for the following scripts for WinXP:

Normal Shutdown
Normal Restart
Normal Hibernate
Forced Shutdown
Forced Restart
Forced Hibernate

Help appreciated for any scripts submitted.
Carlos



Fri, 07 May 2004 09:18:21 GMT  
 Scripts needed for WinXP shutdown..
Set wmi = GetObject("winmgmts:{(Shutdown)}")
set objset = wmi.instancesof("win32_operatingsystem")
for each obj in objset
  set os = obj :  exit for 'only 1 os but returned in a collection
next
os.Win32shutdown iValue

where iValue is one of
      0 Log Off
      0 + 4 Forced Log Off
      1 Shutdown
      1 + 4 Forced Shutdown
      2 Reboot
      2 + 4 Forced Reboot
      8 Power Off
      8 + 4 Forced Power Off

Regards,
Ian
http://communities.msn.com/windowsscript

Quote:
> Dear all,

> I'm looking for the following scripts for WinXP:

> Normal Shutdown
> Normal Restart
> Normal Hibernate
> Forced Shutdown
> Forced Restart
> Forced Hibernate

> Help appreciated for any scripts submitted.
> Carlos



Fri, 07 May 2004 12:41:32 GMT  
 Scripts needed for WinXP shutdown..
Hi Ian.

Can I convert this logic into shutdown event waiting?
If that is possible, how can I do?


Quote:
> Set wmi = GetObject("winmgmts:{(Shutdown)}")
> set objset = wmi.instancesof("win32_operatingsystem")
> for each obj in objset
>   set os = obj :  exit for 'only 1 os but returned in a collection
> next
> os.Win32shutdown iValue

> where iValue is one of
>       0 Log Off
>       0 + 4 Forced Log Off
>       1 Shutdown
>       1 + 4 Forced Shutdown
>       2 Reboot
>       2 + 4 Forced Reboot
>       8 Power Off
>       8 + 4 Forced Power Off

> Regards,
> Ian
> http://communities.msn.com/windowsscript


> > Dear all,

> > I'm looking for the following scripts for WinXP:

> > Normal Shutdown
> > Normal Restart
> > Normal Hibernate
> > Forced Shutdown
> > Forced Restart
> > Forced Hibernate

> > Help appreciated for any scripts submitted.
> > Carlos



Fri, 07 May 2004 14:05:59 GMT  
 Scripts needed for WinXP shutdown..
I thought something like this migh work but it seems that the script to
catch the event gets killed by the shutdown process.
Chances are that you can't use Win32_ComputerShutdownEvent this way

Set oWMI = GetObject("winMgmts:")
set oWMISync =
Wscript.CreateObject("WbemScripting.SWbemSink","WMIEventSync_")

strQuery = "Select * from Win32_ComputerShutdownEvent"
oWMI.ExecNotificationQueryAsync oWMISync, strQuery
WScript.Echo "Waiting for event"
Sub WMIEventSync_OnObjectReady(oEvent, oContext)
   WScript.Echo oEvent.Type
End Sub

Regards,
Ian
http://communities.msn.com/windowsscript

Quote:
> Hi Ian.

> Can I convert this logic into shutdown event waiting?
> If that is possible, how can I do?



> > Set wmi = GetObject("winmgmts:{(Shutdown)}")
> > set objset = wmi.instancesof("win32_operatingsystem")
> > for each obj in objset
> >   set os = obj :  exit for 'only 1 os but returned in a collection
> > next
> > os.Win32shutdown iValue

> > where iValue is one of
> >       0 Log Off
> >       0 + 4 Forced Log Off
> >       1 Shutdown
> >       1 + 4 Forced Shutdown
> >       2 Reboot
> >       2 + 4 Forced Reboot
> >       8 Power Off
> >       8 + 4 Forced Power Off

> > Regards,
> > Ian
> > http://communities.msn.com/windowsscript


> > > Dear all,

> > > I'm looking for the following scripts for WinXP:

> > > Normal Shutdown
> > > Normal Restart
> > > Normal Hibernate
> > > Forced Shutdown
> > > Forced Restart
> > > Forced Hibernate

> > > Help appreciated for any scripts submitted.
> > > Carlos



Fri, 07 May 2004 15:51:30 GMT  
 Scripts needed for WinXP shutdown..
Thanks Ian.
As you expected it doesn't work.
I had posted same event sub in wbem n.g. and was waiting answer hopelessly.
Document say Win32_ComputerShutdownEvent is added for Whistler.
Weird thing is that it never reports error on my win2000server machine.
Only what it does is raising sink_onCompleted just when it starts. And it's
all.
sink_onObjectReady is never raised.


Quote:
> I thought something like this migh work but it seems that the script to
> catch the event gets killed by the shutdown process.
> Chances are that you can't use Win32_ComputerShutdownEvent this way

> Set oWMI = GetObject("winMgmts:")
> set oWMISync =
> Wscript.CreateObject("WbemScripting.SWbemSink","WMIEventSync_")

> strQuery = "Select * from Win32_ComputerShutdownEvent"
> oWMI.ExecNotificationQueryAsync oWMISync, strQuery
> WScript.Echo "Waiting for event"
> Sub WMIEventSync_OnObjectReady(oEvent, oContext)
>    WScript.Echo oEvent.Type
> End Sub

> Regards,
> Ian
> http://communities.msn.com/windowsscript


> > Hi Ian.

> > Can I convert this logic into shutdown event waiting?
> > If that is possible, how can I do?



> > > Set wmi = GetObject("winmgmts:{(Shutdown)}")
> > > set objset = wmi.instancesof("win32_operatingsystem")
> > > for each obj in objset
> > >   set os = obj :  exit for 'only 1 os but returned in a collection
> > > next
> > > os.Win32shutdown iValue

> > > where iValue is one of
> > >       0 Log Off
> > >       0 + 4 Forced Log Off
> > >       1 Shutdown
> > >       1 + 4 Forced Shutdown
> > >       2 Reboot
> > >       2 + 4 Forced Reboot
> > >       8 Power Off
> > >       8 + 4 Forced Power Off

> > > Regards,
> > > Ian
> > > http://communities.msn.com/windowsscript


> > > > Dear all,

> > > > I'm looking for the following scripts for WinXP:

> > > > Normal Shutdown
> > > > Normal Restart
> > > > Normal Hibernate
> > > > Forced Shutdown
> > > > Forced Restart
> > > > Forced Hibernate

> > > > Help appreciated for any scripts submitted.
> > > > Carlos



Fri, 07 May 2004 20:53:35 GMT  
 Scripts needed for WinXP shutdown..
Just a "minor" note:

0 + 4 (Forced Log Off):

Windows 2000: Forced logoff
Windows XP: Forced shutdown

I think this is a bug in the WMI implementation on Windows XP.

--
torgeir

Quote:

> Set wmi = GetObject("winmgmts:{(Shutdown)}")
> set objset = wmi.instancesof("win32_operatingsystem")
> for each obj in objset
>   set os = obj :  exit for 'only 1 os but returned in a collection
> next
> os.Win32shutdown iValue

> where iValue is one of
>       0 Log Off
>       0 + 4 Forced Log Off
>       1 Shutdown
>       1 + 4 Forced Shutdown
>       2 Reboot
>       2 + 4 Forced Reboot
>       8 Power Off
>       8 + 4 Forced Power Off

> Regards,
> Ian
> http://communities.msn.com/windowsscript


> > Dear all,

> > I'm looking for the following scripts for WinXP:

> > Normal Shutdown
> > Normal Restart
> > Normal Hibernate
> > Forced Shutdown
> > Forced Restart
> > Forced Hibernate

> > Help appreciated for any scripts submitted.
> > Carlos



Fri, 07 May 2004 21:16:10 GMT  
 Scripts needed for WinXP shutdown..
Dear Ian,

Thanks for submitting your script!
I'm trying to make forced power off work with your script:

Set wmi = GetObject("winmgmts:{(Shutdown)}")
set objset = wmi.instancesof("win32_operatingsystem")
for each obj in objset
  set os = obj :  exit for 'only 1 os but returned in a collection
next
os.Win32shutdown 8 + 4

The only problem is that just before power off  i get the message:

The dial-up networking connection is currently active.
Would you like to close this connection?

and the PC never powers off..

I just want the PC to ask no questions whatsoever and power off.
Any ideas?


Quote:
> Set wmi = GetObject("winmgmts:{(Shutdown)}")
> set objset = wmi.instancesof("win32_operatingsystem")
> for each obj in objset
>   set os = obj :  exit for 'only 1 os but returned in a collection
> next
> os.Win32shutdown iValue

> where iValue is one of
>       0 Log Off
>       0 + 4 Forced Log Off
>       1 Shutdown
>       1 + 4 Forced Shutdown
>       2 Reboot
>       2 + 4 Forced Reboot
>       8 Power Off
>       8 + 4 Forced Power Off

> Regards,
> Ian
> http://communities.msn.com/windowsscript


> > Dear all,

> > I'm looking for the following scripts for WinXP:

> > Normal Shutdown
> > Normal Restart
> > Normal Hibernate
> > Forced Shutdown
> > Forced Restart
> > Forced Hibernate

> > Help appreciated for any scripts submitted.
> > Carlos



Sat, 08 May 2004 07:23:37 GMT  
 Scripts needed for WinXP shutdown..

Quote:

> I'm trying to make forced power off work with your script:

> The only problem is that just before power off  i get the message:

> The dial-up networking connection is currently active.
> Would you like to close this connection?

> and the PC never powers off..

> I just want the PC to ask no questions whatsoever and power off.
> Any ideas?

It should have waited a bit, and then just shut down (that is what happens if
you have a unsaved document, it will ask you to save it, but if you ignore the
request, it will shut down anyway). If this doesn't happen, the dial-up dialog
box is too "strong" for the shutdown ;-). In that case, see if you can use e.g.
rasphone.exe from the script to close down your dial-up networking connection
before doing the shutdown.

--
torgeir



Sat, 08 May 2004 07:38:27 GMT  
 Scripts needed for WinXP shutdown..
Always issue
    rasdial /disconnect
before the shutdownscript
Quote:
> > I'm trying to make forced power off work with your script:

> > The only problem is that just before power off  i get the message:

> > The dial-up networking connection is currently active.
> > Would you like to close this connection?

> > and the PC never powers off..

> > I just want the PC to ask no questions whatsoever and power off.
> > Any ideas?



Sat, 08 May 2004 21:42:45 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Scripting engine under WinXP Pro?

2. WinXP and script Encode

3. strange scripting problem in IE6 on WinXP

4. Scripting engine under WinXP Pro?

5. Script Fails Behind WinXP Screensaver

6. WinXP: Remote assistance and scripting

7. strange scripting problem in IE6 on WinXP

8. SHUTDOWN SCRIPT

9. Restart/Shutdown Script

10. Run Shutdown Script w/ Alternate Credentials

11. Startup/Shutdown-script and User Profiles

12. Script to Shutdown or LogOff Windows XP

 

 
Powered by phpBB® Forum Software