Sign in with
Sign up | Sign in
Your question
Solved

Windows Script for Networking

Last response: in Networking
Share
September 8, 2012 9:22:56 PM

Good afternoon.
I have a Script Bach files that I run for getting information form PCs.
Some of how it all works in the BATCH file looks like this:

@echo off
:p rompt
color 1f
cls
:o ptions
cls
echo =====================
echo MENU OPTIONS :
echo =====================
echo 1 PING
echo 2 TRACERT
echo =====================
echo Q - Quit
echo =====================
set /p input="Enter Options Here: "

if "%input%"=="1" goto:p ING
if "%input%"=="2" goto:TRACERT
if "%input%"=="q" goto:exit
echo Please choose from the Options listed above!
pause
goto:o ptions

:p ING
set /p host="Enter Host to ping: "
ping "%host%"
pause
goto options

:TRACERT
set /p host="Enter Host to tracert: "
tracert %host%"
pause
goto:o ptions

:exit
exit

====================================
Ok now here is my issue!

With the above setup, at each entry I have to enter in the IP or Host name of the PC over and over.
Is it possible to switch it so that I get asked the IP or Hostname once and then be able to run "all" the commands in the menu from that single entry?

I guess I need an example to:

1 - Enter the IP/Host address
set /p input="What is the Host of the PC your working on?:"

2 - GOTO for each command to use the IP address that I just entered.

3 - I know I can close the Batch file to reset it, however is it possible to have a RESET option in the menu so that I can enter in the next IP/Host address?

Any help that you can throw my way would be great. Thank you
September 8, 2012 9:43:47 PM

This looks suspiciously like a class assignment.
m
0
l
September 8, 2012 10:02:46 PM

No Honestly! :)  It's not really.
I work at a IT Help Desk at a local bank and I haven't played around with scripts for almost 20 years.
I not sure if one can get the initial IP to be used for all the commends and especially having someway to reset it for the next IP address?
m
0
l

Best solution

September 8, 2012 10:21:27 PM

Ok.

Call the batch with the IP address as a parameter.

This link should help: http://www.microsoft.com/resources/documentation/window...

Although, if all this script does is run those two commands, I really don't see the need for all that code. It's not that hard to type:

"ping xxx.xxx.xxx.xxx/<hostname>"

or

"tracert xxx.xxx.xxx.xxx/<hostname>"


probably much faster that way as well.
Share
!