I need a Shutdown command with prompt

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
1vadens
Posts: 2
Joined: 15 Sep 2010 22:13

I need a Shutdown command with prompt

#1 Post by 1vadens » 15 Sep 2010 22:20

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?

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: I need a Shutdown command with prompt

#2 Post by phillid » 15 Sep 2010 23:19

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

1vadens
Posts: 2
Joined: 15 Sep 2010 22:13

Re: I need a Shutdown command with prompt

#3 Post by 1vadens » 15 Sep 2010 23:42

Looks like exactly what I need. Thanks very much!

Post Reply