What is wrong with this Windows shutdown command?

12

1

I am using Windows 7 and XP. I want to run a script to run this command:

shutdown /p /f /t 120

On Windows 7, it shows that an error occurred, but I think I am using it correctly.

software is fun

Posted 2014-03-11T17:07:09.307

Reputation: 415

12What error? Is there a specific error you can quote here for us to see? – CharlieRB – 2014-03-11T17:09:52.613

Answers

40

You are using conflicting switches.

  • /p – Turn off the local computer with no time-out or warning. Can be used with the /f option.

  • /t – Set the time-out period before shutdown to xxx seconds.

You are telling it to shutdown now with /p and shutdown in 120 seconds with /t.

Keltari

Posted 2014-03-11T17:07:09.307

Reputation: 57 019

11Learn something new... I always do /s /f /t 0... glad to know I can be lazy and just do /p /f now. That's five key strokes I'll save! – WernerCD – 2014-03-11T18:27:56.313

5

You should use

shutdown /f /t 120

Parameters /p and /t are incompatible.

Check Windows 7 shutdown command syntax for other parameters and more info.

Oscar Foley

Posted 2014-03-11T17:07:09.307

Reputation: 177

1you need a toggle for shutdown: R for restart, S for shutdown, H for hibernate, P for shutdown now (can't use T), etc. /f /t 120, etc – WernerCD – 2014-03-11T20:45:54.290

1

Depending on what you are trying to achieve, you might want to try

shutdown -s -f -t 120

This will force close all running programs and shut your computer down after 120 seconds.

user307052

Posted 2014-03-11T17:07:09.307

Reputation: 11