Page 1 of 1

How do I create a batch file to prompt for a name to ping?

Posted: 17 Oct 2013 09:07
by anoble1
Hi,

Am trying to figure out how to make a batch file that will give a prompt to enter a PC name or printer and and perform the ping ******-t command.
I can get the prompt to come up, but can't tie 2 together. Any help?

Thanks,

Re: How do I create a batch file to prompt for a name to pin

Posted: 17 Oct 2013 09:51
by ElizabethGreene
Hello.

Like this:

Code: Select all

@echo off
set /P Target=Please enter the name of the host to ping:
ping %Target%



If you want to be really sexy:

Code: Select all

@echo off
:targetprompt
set /P target=Please enter the name of the host to ping:
if "%target%"=="" (
  echo A target is required, or you can press CTRL-C to cancel
  goto targetprompt
)
ping %target%


Glad to help.
Elizabeth Greene
ExtraParts.Info

Re: How do I create a batch file to prompt for a name to pin

Posted: 17 Oct 2013 09:56
by anoble1
That's what I am talking about. Worked like a champ!

Thanks!!!!