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.

Dani AI

Generated

Good troubleshooting so far. The syntax problem that fixed is the most common cause of a command "doing nothing" — spaces in the wrong place break the parser — and / were right to flag switch format and the possibility of a non-standard shutdown binary on PATH. A few focused checks will pin down the hover/countdown behaviour and rule out third‑party tools or malware.

A quick verification step: determine which shutdown executable is actually being invoked. On Vista/7/10+ the built‑in helper will be shown by the where tool; on older XP-era installs a full‑drive search will locate any replacement shutdown.exe.

where shutdown.exe

dir /b /s c:\shutdown.exe

If a copy outside System32 appears earlier on PATH, run the System32 copy directly (or use the full path) and compare behaviour. Also run the test from an elevated prompt (Run as Administrator) to remove permission as a variable.

About the countdown freezing when the mouse hovers: that is not normal for the stock Windows shutdown dialog. Two practical possibilities are (a) a third‑party shutdown/notification utility that intentionally pauses on hover, or (b) a shutdown triggered by a task that cancels when user activity is detected. To distinguish these, test the System32 shutdown, test a scheduled task run as SYSTEM (no interactive shell), and check whether the same pause happens.

If a silent, non-interactive shutdown is desired (it avoids the visible countdown), a small WMI script will invoke the shutdown without the shell balloon. Example VBScript (save as .vbs and run elevated):

strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOS = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOS
  objOS.Win32Shutdown(5)
Next

For the historical recurring shutdown mentioned: inspect Startup folders, the HKLM/HKCU Run keys, and Task Scheduler entries for any .bat/.vbs launching shutdown, and run an up‑to‑date antivirus/anti‑malware scan. Forced shutdowns risk data loss, so any prank should avoid production or work machines.

Recommended Answers

All 5 Replies

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. ;)


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.