Page 1 of 1

I need a Shutdown command with prompt

Posted: 15 Sep 2010 22:20
by 1vadens
I want to create a shutdown command using a batch script that will prompt me for the computer name. I have been using this cmd line {shutdown /m \\mycomputer /s /t 0} to restart a computer on my network. It works great. I have to keep changing the mycomputer to whatever computer I am targeting. I was wondering if someone knew of a way to create a batch script that would run a cmd prompt that would ask you what computer name you are targeting?

Re: I need a Shutdown command with prompt

Posted: 15 Sep 2010 23:19
by phillid
I think this is the sort of thing you are talking about:

Code: Select all

@echo off
:: ask the user for computer name
:prompt
echo  Computer Name:
set /p "comp_name=> "
::Check for blank input variable
if not defined comp_name (
echo Please enter a computer name!
goto prompt
)
::Shut the remote machine down
echo Shutting down %comp_name%
shutdown /m \\%compname% /s /t 0
echo.
pause


:D
phillid

Re: I need a Shutdown command with prompt

Posted: 15 Sep 2010 23:42
by 1vadens
Looks like exactly what I need. Thanks very much!