hey there. first off, i hope i posted my question in the right forum. second, i thank you in advance for an answer.

i have two short batch files:

1. shutdown - s - c "my message" - t 20

i expect this to shut down my computer in twenty seconds, but the file actually does absolutely nothing. i can't figure out what the problem is. i tried to rearrange the order of s, c and t, but nothing happens. even if i add -f, the file won't work.

2. shutdown -s -f

this file does work, but not the way i expected it would. note that i did not specify the time it should wait before it shuts down my pc but it set the time before shutdown to 30 seconds. ok, i guess there is a default value for it but my greater problem is that if i start the file, the usual little System Shutdown window appears telling me that the system is shutting down. however, if i hover over it with my cursor, the countdown stops, and it never dose its job. besides, i cannot close the little window neither clicking the X button nor throught task manager after hovering over it.

i am aware there are many questions i posed; whatever you answer, i'll learn something as i am very new to these types of things. i am trying to build a shutdown prank to mess with my family - I hope you do not find that overly mean.

It would have been helpful if you had posted your actual batch file, but anyway.... beware of spaces between parameters, and between parameters and their fields. They MUST be there. Wrong format, and it just will not run.
I have the distinct feeling that the people who wrote these command structures were many, and they did not talk to each other.

Open a command prompt and type "SHUTDOWN /?"

What is the result? Does it display usage info, or do you get a "not found" error? If you get a "not found" error, then the shutdown command is not installed or not available via the PATH. Search for shutdown.exe and use the full path in your batch file if it does exist (ie C:\Windows\Extras\Shutdown.exe /s /c "shutting down now!" /t 20). In earlier system releases, shutdown was a resource-kit component and not installed by default.

When I run it on my system, it shows that the parameters are introduced with a "/", not a "-". That's often significant - so check on your PC. Make sure that there are no spaces between the "/" and the parameter.

Finally, specifying /T ## implies /F, so that isn't necessary.

Glenn

PS - it's only mean if you do it often, and don't pay attention to the work they'd lose. ;)

@gerbil
I wrote both files. in the first file, I put spaces between "-" and "s" (or c). soon as I removed the spaces, the code worked. But, hovering over the little System Shutdown window made the countdown stop. otherwise, I took the code from some videos in youtube; I wrote the code, but took it from different people.

@Glenn:
I did the shutdown/? in cmd. I got the usage info. that means the shutdown is available through the path, then.
after that, I replaced "-" with "/" as I think you suggested I do. The behaviour of the file was the same. It would start, but hovering over it would make the countdown stop. I guess the problem that persists is how to make sure the countdown does not stop after my sister tries to close the little window :)

and lastly, a few years ago, I would have this system shutdown message appear around 20 minutes after each time I'd turn my computer on, and it would shut down in four minutes. a friend at the time told me that my hard disk had some deffect cuasing that to happen. now I think he was wrong. I must have had some batch file somehwere installed, right? although, he kept formmatting the disk continuously, but the problem persisted!!!

and lastly, a few years ago, I would have this system shutdown message appear around 20 minutes after each time I'd turn my computer on, and it would shut down in four minutes. a friend at the time told me that my hard disk had some deffect cuasing that to happen. now I think he was wrong. I must have had some batch file somehwere installed, right? although, he kept formmatting the disk continuously, but the problem persisted!!!

that was a virus of the day a few yrs back

If you enter this command you will see the default time that you mention...
shutdown -i
By spaces I meant that they should be between parameters, not between parameters and the separators, so: -s -c "Uh-oh..." is how it should be.
As for the hover action, I do not know. Perhaps a hack to lessen the irritation of an unplanned shutdown? [maybe your virus that caper mentioned had a friendly side?]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.