i would like to schedule windows with task manager to turn off by using .bat
file.
can anyone write the inside body of that file?
regards
Andre
Skip Knoble, Penn State
"Andre" <andr...@poczta.fm> wrote in message
news:b9bdu0$e9n$1...@news.onet.pl...
well ok... I don't want to install anything because it is nor nessesary...
it's quite simple to make .bat file and run it from task scheduler. I know
because I was doing it many times. problem is that i was doing it a long
time ago and now I don't have this .bat and what is more I don't remember
hove to do it. I mean I don't remember what is inside .bat. if you know what
i should put inside please help me :)
regards
Andre
> i would like to schedule windows with task manager to turn off by using .bat
> file.
> can anyone write the inside body of that file?
Hi
The shutdown.exe that comes with WinXP has a bad habit of ending up in "It is
now safe to turn of your computer" message when you do a shutdown.
Using VBScript/WMI works very well for this. Put the following code into a file
called e.g. shutdwn.vbs, run it from the task manager with wscript.exe as the
executable and <path-to-vbs-file> as parameter:
' 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 "LogOff" for a logoff
' Use "LogOff_Force" for a forced logoff
' 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
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
Skip
"Andre" <andr...@poczta.fm> wrote in message
news:b9bu2p$ord$1...@news.onet.pl...
well :) it's quite interesing but too long for me...
thx for reply but i have found it in same polish group
tsshutdn.exe 0 /powerdown /delay:0
as easy as that :))
only one line of command. it workes with win xp (not with 9x)
thank everyone :)
regards
Andre