Question : Problem with "shutdown" DOS command

Hi there, I am trying to create a batch file that will first ask me for a client PC name, then stop the Firewall on that PC, then force it to reboot.

Please see code below.  At the minute the batch file doesn't work.  It asks me for a PC name, then when I enter this it just loops round and goes back to the same prompt, again asking me for a PC name.

Can you see what might be wrong here?  The command to stop the firewall service seems to work OK, but not the shutdown.

I have tested the SHUTDOWN command without variables, i.e.

shutdown -r -f -t 0 -m \\

where I have actually typed in the PC name of a test PC.  And the command works!  So the problem only arises when used with variables retrieved from the SET command.
Code Snippet:
1:
2:
3:
4:
5:
6:
@echo off
echo.
set /p CYFRIFIADUR="Enw'r cyfrifiadur... "
sc \\%CYFRIFIADUR% stop SharedAccess
shutdown -r -f -t 0 -m \\%CYFRIFIADUR%
pause

Answer : Problem with "shutdown" DOS command

Have you tried "start shutdown -r -f -t 0 -m \\%CYFRIFIADUR%" instead of "shutdown -r -f -t 0 -m \\%CYFRIFIADUR%" ?
Random Solutions  
 
programming4us programming4us