shutdown computer at a particular time .bat

3.7k Views Asked by At

I'm trying to shutdown the computer using a BAT file on windows 7 and was wondering if anyone knew how to do it. Here's what I got so far (it doesn't work). Thanks in advance

@echo off
 :W
if %time% == 08:53:00 goto :Y
if %time% == 08:54:00 goto :X
goto :W

 :Y
taskkill /f /IM "iexplore.exe"
 :X
shutdown.exe /s /f /t 60 /c " Sleeeeeeeep " 
2

There are 2 best solutions below

0
On

Any reason you want a .bat file? You can use powershell on Windows 7. Run this in the command prompt and there is no script file to worry about, just a scheduled task like @Andrew mentioned:

schtasks /create /tn "shutdown" /sc daily /st 08:53 /tr "powerShell -command { taskkill /f /IM iexplore.exe; Start-Sleep -Seconds 3600; Stop-Computer -Force }"
0
On

It also works well. you just put it correct time format. it properly works all other windows versions.

Example:

%time%==00:00:0.00

I just modify your time format and run on my computer it perfectly works it.

only you put it 24 hours time format

@echo off
:W
if %time% == 20:53:0.00 goto :Y
if %time% == 20:54:0.00 goto :X
goto :W

:Y
taskkill /f /IM "iexplore.exe"
:X
shutdown.exe /s /f /t 60 /c " Sleep... "