Hello everybody, I am working on a batch file that I'd like to use at work. I'm in the early stage of building this batch file, which will allow me to send to a end user and upon running it, the program will ask them:
If they need a static addres or dynamic
and if it is static, it will ask for a club number and based on the club number it will assign the IP address, SubNet/GW/DNS to the end user's laptop.
is there an easy way to create such variable for each club? Obviously the GW/IP changes at each club location so I'd like to figure out a way of setting a variable, such as: club 5 = IP x.x.x.x and GW x.x.x.x
Any suggestions/tips? thank you!
How to set IP information as variables?
Moderator: DosItHelp
Re: How to set IP information as variables?
If I understand you: You can have a plain text file with a format of "name, IP address, GW address EG:
club5,100.100.100.100,200.200.200.200
club9,102.102.102.102,201.201.201.201
and read it in a for next loop:
club5,100.100.100.100,200.200.200.200
club9,102.102.102.102,201.201.201.201
and read it in a for next loop:
Code: Select all
:loop
set var=
set /p "var=Enter club name: "
if not defined var goto :loop
for /f "tokens=1,2,3 delims=," %%a in ('find /i "%var%" <infofile.txt ') do echo club %var% IP is %%b and GW is %%c