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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
anoble1
Posts: 22
Joined: 29 Nov 2012 10:24

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

#1 Post by anoble1 » 17 Oct 2013 09:07

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,

ElizabethGreene
Posts: 1
Joined: 17 Oct 2013 09:42
Contact:

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

#2 Post by ElizabethGreene » 17 Oct 2013 09:51

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
Last edited by ElizabethGreene on 25 Oct 2013 15:48, edited 1 time in total.

anoble1
Posts: 22
Joined: 29 Nov 2012 10:24

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

#3 Post by anoble1 » 17 Oct 2013 09:56

That's what I am talking about. Worked like a champ!

Thanks!!!!

Post Reply