Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

turning off with .bat file

6 views
Skip to first unread message

Andre

unread,
May 7, 2003, 12:59:13 PM5/7/03
to
hi!

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

unread,
May 7, 2003, 3:24:25 PM5/7/03
to
Andre: Are you saying that you want to shut windows down at a specific
time/date?
If so, then get the neat little app called SwitchOff (free):
http://yasoft.km.ru/eng/
If not, then please make it clearer what you want to do.

Skip Knoble, Penn State

"Andre" <andr...@poczta.fm> wrote in message
news:b9bdu0$e9n$1...@news.onet.pl...

Andre

unread,
May 7, 2003, 5:34:51 PM5/7/03
to
> Andre: Are you saying that you want to shut windows down at a specific
> time/date?
> If so, then get the neat little app called SwitchOff (free):
> http://yasoft.km.ru/eng/
> If not, then please make it clearer what you want to do.


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


Torgeir Bakken (MVP)

unread,
May 7, 2003, 9:29:42 PM5/7/03
to
Andre wrote:

> 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 Knoble

unread,
May 8, 2003, 8:22:24 AM5/8/03
to
Andre: SwitchOff is very small and better than you can do with a scheduler.
But
if you want the command for a .BAT file see:
http://support.microsoft.com/?scid=kb;en-us;Q234216
"How to Exit Windows 98/Me Automatically Using a Batch File"

Skip

"Andre" <andr...@poczta.fm> wrote in message

news:b9bu2p$ord$1...@news.onet.pl...

Andre

unread,
May 8, 2003, 5:57:11 PM5/8/03
to
[cut]

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


0 new messages