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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IP address 6

Status
Not open for further replies.

prija

Programmer
Oct 17, 2002
28
0
0
YU
How to save a different IP address on my laptop computer.
What is the problem? I change my office from town to town, and then I change network too. When I arrive to a destination, first I must ask my friends to tell me what is the IP address in his network, and then I must change it.
Thus it someone know, how to configure a few deferent IP address to a local area connection on the same computer.
Is this possible?
 
Taken from (the site has changed so I can't find the exact link, but here is an excerpt from my cached copy)
*******************************************
To save your current IP settings:

netsh -c interface dump > c:\data\interface.txt

To restore (or configure) your settings from a text file:
netsh -f c:\data\interface.txt

If you need to plug your laptop into different networks, you can save and restore the appropriate network configuration using netsh.exe. 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 command to restore your office network interface:

netsh -f c:\configs\officeinterface.txt

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

netsh -f c:\configs\homeinterface.txt

Hope this helps.
 
Cool stuff REDLIKEME, but I'll do you one better and provide a script that will do all of what you said.

'==========================================================================
'
' NAME: IPSwitcher.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: ' DATE : 3/23/2004
'
' COMMENT: <comment>
'
'==========================================================================


Dim fso,WSHShell



Set fso = CreateObject("Scripting.FileSystemObject")
Set WSHSHell = CreateObject("Wscript.Shell")
Path = "C:\IPCONFIGS"

'Create Storage location if not already there
If Not fso.FolderExists(Path) Then
fso.CreateFolder(Path)
End If


'Prompt to activate, create or delete a config
Action = InputBox("Do you want to ACTIVATE, SAVE or DELETE an IP Configuration","What should I do?")
Action = UCase(Action)

Call ConfigList


Select Case Action

Case "ACTIVATE"
If Len(ConfigList) >0 Then
What = InputBox("Existing configurations are:" & vbCrLf & ConfigList & vbCrLf & "Enter config name to activate.","Activate Which Configuration")
FileName = Path & "\" & What & ".txt"
WSHShell.Run ("netsh -f " & FileName)
Else
MsgBox "Sorry there are no configurations to activate"
End If

Case "SAVE"
If Len(ConfigList) >0 Then
What = InputBox("Existing configurations are:" & vbCrLf & ConfigList & vbCrLf & "Enter new config name to save, enter existing name to overwrite.","Save Configuration")
Else
What = InputBox("Enter new config name to save.","Save Configuration")
End If
FileName = Path & "\" & What & ".txt"
'MsgBox Filename
WSHShell.Run ("netsh -c interface dump >" & FileName)

Case "DELETE"
If Len(ConfigList) >0 Then
What = InputBox("Existing configurations are:" & vbCrLf & ConfigList & vbCrLf & "Enter config name to delete.","Delete Configuration")
FileName = Path & "\" & What & ".txt"
fso.DeleteFile(FileName)
Else
MsgBox "No configurations saved to delete."
End If

End Select
MsgBox "Done"

Function ConfigList
'Read the existing configs
Set oFolder = fso.GetFolder(Path)

ThisList = ""
For Each oFile In oFolder.files
ThisConfigLength = (Len(oFile.Name)-4)
ThisConfig = Left(oFile.Name,ThisConfigLength)
ThisList = ThisList & ThisConfig & vbCrLf
Next
ConfigList = ThisList

End Function

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
I wrote this this morning on my XP box. I had a chance to test this out on a Win2K box this afternoon and found it necessary to first open a command prompt to get this to work. I have updated the code to do that and to display the configurations saved in UPPERCASE for readbility.


'==========================================================================
'
' NAME: IPSwitcher.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: ' DATE : 3/23/2004
'
' COMMENT: <comment>
'
'==========================================================================


Dim fso,WSHShell



Set fso = CreateObject("Scripting.FileSystemObject")
Set WSHSHell = CreateObject("Wscript.Shell")
Path = "C:\IPCONFIGS"

'Create Storage location if not already there
If Not fso.FolderExists(Path) Then
fso.CreateFolder(Path)
End If


'Prompt to activate, create or delete a config
Action = InputBox("Do you want to ACTIVATE, SAVE or DELETE an IP Configuration","What should I do?")
Action = UCase(Action)

Call ConfigList


Select Case Action

Case "ACTIVATE"
If Len(ConfigList) >0 Then
What = InputBox("Existing configurations are:" & vbCrLf & vbCrLf & ConfigList & vbCrLf & "Enter config name to activate.","Activate Which Configuration")
FileName = Path & "\" & What & ".txt"
WSHShell.Run ("cmd /c netsh -f " & FileName)
Else
MsgBox "Sorry there are no configurations to activate"
End If

Case "SAVE"
If Len(ConfigList) >0 Then
What = InputBox("Existing configurations are:" & vbCrLf & vbCrLf & ConfigList & vbCrLf & "Enter new config name to save, enter existing name to overwrite.","Save Configuration")
Else
What = InputBox("Enter new config name to save.","Save Configuration")
End If
FileName = Path & "\" & What & ".txt"
'MsgBox Filename
WSHShell.Run ("cmd /c netsh -c interface dump >" & FileName)

Case "DELETE"
If Len(ConfigList) >0 Then
What = InputBox("Existing configurations are:" & vbCrLf & vbCrLf & ConfigList & vbCrLf & "Enter config name to delete.","Delete Configuration")
FileName = Path & "\" & What & ".txt"
fso.DeleteFile(FileName)
Else
MsgBox "No configurations saved to delete."
End If

End Select
MsgBox "Done"

Function ConfigList
'Read the existing configs
Set oFolder = fso.GetFolder(Path)

ThisList = ""
For Each oFile In oFolder.files
ThisConfigLength = (Len(oFile.Name)-4)
ThisConfig = Left(oFile.Name,ThisConfigLength)
ThisList = ThisList & ThisConfig & vbCrLf
Next
ConfigList = UCase(ThisList)

End Function

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Great posts all. I just recently discovered the netsh command, and this is a great use for it. I gave redlikeme a star yesterday. Today a user called in that needs this exact thing; the VBS script will make it easy for her. Star to markdmac too.
 
Glad to be of service crobin1. Thanks for the Star. Always nice to be appreciated.



I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top