Can I schedule Windows (XP) shutdowns?

Muse

Lifer
Jul 11, 2001
40,915
10,228
136
I thought I heard I could do this with Windows Scheduler, but looking at it I don't see it. I seem to be required to pick a program to run at the scheduled day/time from the list of installed programs. I use a freeware program called Poweroff to shut down one of my PCs daily at a certain time, but that doesn't allow me to make day-specific shutdowns. Am I missing something? Or is there another program/utility I can use to do this?
 

Ryland

Platinum Member
Aug 9, 2001
2,810
13
81
You should be able to schedule System32\shutdown.exe using the the task scheduler which will shut your machine down. Look at Help for what switches to use.
 

Muse

Lifer
Jul 11, 2001
40,915
10,228
136
Originally posted by: Ryland
You should be able to schedule System32\shutdown.exe using the the task scheduler which will shut your machine down. Look at Help for what switches to use.

Hmm, I don't know how to find those switches. I scheduled a task and since Shutdown.exe isn't in the list of installed programs I used the Browse button to find C:\windows\system32\shutdown.exe. When I set up the task I got a message that the task might not run, reason being "Access is denied." It cited some code, something like x00008156 (I made up that string, but it looked kind of like that). It said I could use the browse facility to find the application. I guess there's a way, but I haven't found it yet. I set a trial run to shut a few minutes ago but the machine did nothing. I also set a task to shutdown at 11:57 PM every Saturday night (something I want to happen if the machine is on), but I got a similar message and I don't expect that to work. I do have administrator status, so that's not the issue.
 

DrGreen2007

Senior member
Jan 30, 2007
748
0
76
You can look for shutgui.exe from the nt resource kit, you can make a batch file that can schedule shutdowns and reboots..I use it at work and home, pretty decent, and free
 

TallBill

Lifer
Apr 29, 2001
46,017
62
91
Originally posted by: DrGreen2007
You can look for shutgui.exe from the nt resource kit, you can make a batch file that can schedule shutdowns and reboots..I use it at work and home, pretty decent, and free

Was gonna suggest batch files myself. So useful.
 

Ryland

Platinum Member
Aug 9, 2001
2,810
13
81
I know I have used shutdown.exe on my Vista box and I think I have used it on my XP box. I don't know why you are getting an access denied error unless you aren't running as an admin.
 

Muse

Lifer
Jul 11, 2001
40,915
10,228
136
Originally posted by: Ryland
I know I have used shutdown.exe on my Vista box and I think I have used it on my XP box. I don't know why you are getting an access denied error unless you aren't running as an admin.

Well, I'm not logging off and then logging onto the Administrator account to set this thing up. However, I am in the Administrators Group, so I wouldn't think that necessary. I have no idea what's up with this.

I think I will try setting up a batch file that calls shutdown.exe and see if the Task Scheduler will call that. I'm not hopeful, though.

shutgui.exe in the nt resource kit? Do I have to download that? I wonder if I will have the same trouble with that. :confused:
 

Muse

Lifer
Jul 11, 2001
40,915
10,228
136
What do I put in the .bat file? Just the following line?

c:\windows\system32\shutdown.exe

I just ran that file and a DOS window flashed on the screen OK but the machine didn't start the shutdown process.
 

2canSAM

Diamond Member
Jul 16, 2000
3,390
4
81
Paste this into notepad and save as shutdown.bat, make sure you select all file types to force it to save as a batch file and not a txt file.

c:\windows\system32\shutdown.exe -s -f -t 10

Then point Task Scheduler to the batch file and run it as Administrator. I just tested this logged on a restricted user and it ran just fine. The -s means to shutdown (replace with -r if you want the pc to reboot) the -f means force an unresponsive application to close and the -t 10 means delay the shutdown 10 seconds. A message will pop up saying the system is shutting down in 10 seconds and who initiated it, this should be the administrator account of your PC.
 

Muse

Lifer
Jul 11, 2001
40,915
10,228
136
Originally posted by: 2canSAM
Paste this into notepad and save as shutdown.bat, make sure you select all file types to force it to save as a batch file and not a txt file.

c:\windows\system32\shutdown.exe -s -f -t 10

Then point Task Scheduler to the batch file and run it as Administrator. I just tested this logged on a restricted user and it ran just fine. The -s means to shutdown (replace with -r if you want the pc to reboot) the -f means force an unresponsive application to close and the -t 10 means delay the shutdown 10 seconds. A message will pop up saying the system is shutting down in 10 seconds and who initiated it, this should be the administrator account of your PC.

That's a thing of beauty. Thanks!
 

Muse

Lifer
Jul 11, 2001
40,915
10,228
136
Originally posted by: Muse
Originally posted by: 2canSAM
Paste this into notepad and save as shutdown.bat, make sure you select all file types to force it to save as a batch file and not a txt file.

c:\windows\system32\shutdown.exe -s -f -t 10

Then point Task Scheduler to the batch file and run it as Administrator. I just tested this logged on a restricted user and it ran just fine. The -s means to shutdown (replace with -r if you want the pc to reboot) the -f means force an unresponsive application to close and the -t 10 means delay the shutdown 10 seconds. A message will pop up saying the system is shutting down in 10 seconds and who initiated it, this should be the administrator account of your PC.

That's a thing of beauty. Thanks!

I ran it and it worked. I had 10 seconds but no option to cancel the shutdown, which would be nice.

I'm curious about the saving it as All File type and not a text file. I thought that as long as the file extension was .bat it would run as a batch file automatically even if created in a text editor. I did as you said, but wouldn't it have worked if I just saved as a text file and then made sure the extension was .bat?
 

2canSAM

Diamond Member
Jul 16, 2000
3,390
4
81
Originally posted by: Muse
Originally posted by: Muse
Originally posted by: 2canSAM
Paste this into notepad and save as shutdown.bat, make sure you select all file types to force it to save as a batch file and not a txt file.

c:\windows\system32\shutdown.exe -s -f -t 10

Then point Task Scheduler to the batch file and run it as Administrator. I just tested this logged on a restricted user and it ran just fine. The -s means to shutdown (replace with -r if you want the pc to reboot) the -f means force an unresponsive application to close and the -t 10 means delay the shutdown 10 seconds. A message will pop up saying the system is shutting down in 10 seconds and who initiated it, this should be the administrator account of your PC.

That's a thing of beauty. Thanks!

I ran it and it worked. I had 10 seconds but no option to cancel the shutdown, which would be nice.

I'm curious about the saving it as All File type and not a text file. I thought that as long as the file extension was .bat it would run as a batch file automatically even if created in a text editor. I did as you said, but wouldn't it have worked if I just saved as a text file and then made sure the extension was .bat?

I think it depends on if you have XP set to hide registered file types. I have mine set to show all file extensions so I can just name it shutdown.bat and it behave as you say, if you have the option to "hide known file extensions" and save it as shutdown.bat it will actually save it as shutdown.bat.txt. I am not sure about a cancel switch but will see what I can find.
 

Muse

Lifer
Jul 11, 2001
40,915
10,228
136
Originally posted by: 2canSAM
Originally posted by: Muse
Originally posted by: Muse
Originally posted by: 2canSAM
Paste this into notepad and save as shutdown.bat, make sure you select all file types to force it to save as a batch file and not a txt file.

c:\windows\system32\shutdown.exe -s -f -t 10

Then point Task Scheduler to the batch file and run it as Administrator. I just tested this logged on a restricted user and it ran just fine. The -s means to shutdown (replace with -r if you want the pc to reboot) the -f means force an unresponsive application to close and the -t 10 means delay the shutdown 10 seconds. A message will pop up saying the system is shutting down in 10 seconds and who initiated it, this should be the administrator account of your PC.

That's a thing of beauty. Thanks!

I ran it and it worked. I had 10 seconds but no option to cancel the shutdown, which would be nice.

I'm curious about the saving it as All File type and not a text file. I thought that as long as the file extension was .bat it would run as a batch file automatically even if created in a text editor. I did as you said, but wouldn't it have worked if I just saved as a text file and then made sure the extension was .bat?

I think it depends on if you have XP set to hide registered file types. I have mine set to show all file extensions so I can just name it shutdown.bat and it behave as you say, if you have the option to "hide known file extensions" and save it as shutdown.bat it will actually save it as shutdown.bat.txt. I am not sure about a cancel switch but will see what I can find.
Looks like the only way to cancel is to go to a command prompt during the timeout and enter something like the following:

shutdown /l /a /y

I imagine that I could put that in a batch file, but I'm not really concerned. I'm not likely to be at the machine when my shutdowns happen.

Yes, I always show filie extensions. It's a habit I have always been in since I took my DOS class!