Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IP setting using batch file

Status
Not open for further replies.

cybercop23

IS-IT--Management
Aug 12, 2001
103
US
Hello all. I have several users that move from location to location. Each of the locations have their own private network. (10.01.xx.xx, 10.02.xx.xx.) My users do have laptops and I know the easiest way is to have a DHCP in each location or one centeral. But since I can't, and these users will have a hard time changing the IP manually, I was wondering if there is a way I can set the IP, mask and gateway via a batch file.
What I want to be able to do is pass the location nmber and a sequence number to the batch and have it set that system's IP, subnet and gateway.

Something like this:
logon2location.bat 001 5
-where 001 will be an area in the batch that sets the right IP, subnet and gateway - and 5 if the last sequence in the IP schema. This should result in:
IP: 10.1.23.5 / Subnet (always the same 255.255.255.0) and a gateway of 10.1.23.1.

Anyway, hope this is clear enought.

Thanks much,
Mike
 
Anne,
I'll look more into these programs.
However, since these setting are in the registry under
HLM\System\ControlSet001\Services.....
As IpAddress,Defaultgateway and Submask.
Can I set these registry setting using a batch and reboot the machine? I think these programs do the same thing, in essence.
Any suggestions will be helpful.

Thanks,
 
They are the same settings, however there is a lot more info in there. If you were to configure the system, then export the key, you would create a .reg file that coould be reimported and used whenever required. CurrentControlSet is actually the key that is in use. ControlSet001/002 are backups. Depending on the OS, this is not the only location IP configuration is stored. DCHP is in separate key.
 
Use a W2K/XP tools - NETSH.EXE - it's free ......!

[I quote]

"If you need to plug your laptop into different networks, you can save and restore the appropriate network configuration using the netsh.exe utility which ships with W2K and XP. When you have your laptop correctly configured for your office network, you can save the network configuration for later restoration.

netsh -c interface dump > c:\configs\officeinterface.txt

Now lets say you take it home and reconfigure it correctly for you home network. To save you home network configuration for later use:

netsh -c interface dump > c:\configs\homeinterface.txt

OK. Now you take the laptop back to the office and you need to reconfigure for the office environment: nic address, wins,
gateway address...
Use the following commands to restore your office network interface:

netsh -f c:\configs\officeinterface.txt
ipconfig /renew

At end of day, you take it home. To setup for home, run:

netsh -f c:\configs\homeinterface.txt
ipconfig /renew

These can be made part of two scripts, say, home.bat and office.bat.

As you can imagine, this is very valuable if you have get your laptop to function in multiple network locations."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top