Suppose you need to recreate a virtual machine and you want to make sure you capture the right network settings… and you’re running an older OS. You could write everything down, or you could just use VMNetBac, a free tool from PHD Virtual. The tool’s download page indicates that it only operates on Windows 2000, 2003 and XP machines, but I’ve run it from a Windows Server 2008 R2 machine and it was able to generate the backup script, but the script doesn’t actually run with success. Again, this is a free tool and the company is very up front about its lack of support for Windows Vista and higher operating systems.
Which brings me to my next point: To operate the tool, simply download it and extract the single file from the downloaded ZIP. Execute the file, which is named netbac.vbe. Execution of this script places a file name IPINFO.vbs at the root of the C: drive on the local server.
Back to my machine… the IPINFO.vbs file was written successfully. If I need to rebuild this server, I can execute this file and it will automatically set my network adapters to their current IP addresses – if I was running a supported OS. Even if the script doesn’t actually run successfully under Windows Server 2008 R2 (which it doesn’t), at the very least, the current networking configuration is documented in the IPINFO.vbs file. For older virtual machines, however, the tool might be useful.
Here’s the full text of the IPINFO.vbs file from my test virtual server (note that the comment specifically indicate that the script is for Windows 2000, XP and 2003 machines):
‘ Set IP info and install vmware tools script for
‘ 2k\xp\2k3 – not vista or IPv6 Stacks
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & “\root\default:StdRegProv”)
Set colNetAdapters = objWMIService.ExecQuery(“Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE”)
Dim objShell : Set objShell = CreateObject(“WScript.Shell”)
Call SetIP
Call SetDNS
Call SetWINS
Call SetVGA
Call Reboot
Function SetIP
‘Set IP Address
strIPAddress = “192.168.0.179”
strIPAddress = “fe80::2dc2:cf62:fb72:a033”
strSubnetMask = “255.255.0.0”
strSubnetMask = “64”
strGateway = “192.168.0.1”
objShell.Run “netsh.exe int ip set address name = “”Local Area Connection”” source = static fe80::2dc2:cf62:fb72:a033 64″, 1, TRUE
objShell.Run “netsh.exe int ip set address name = “”Local Area Connection”” gateway = 192.168.0.1 gwmetric = 1″, 1, TRUE
End Function
Function SetDNS
objShell.Run “netsh.exe int ip set dns name = “”Local Area Connection”” source = static addr = 192.168.0.1″, 1, TRUE
End Function
Function SetWINS
End Function
Function SETVGA
Const HKEY_LOCAL_MACHINE = &H80000002
Dim RegValueData
Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv”)
‘Get Path to Acceleration.Level
objReg.GetStringValue HKEY_LOCAL_MACHINE,”HARDWARE\DEVICEMAP\VIDEO”,”\Device\Video0″,RegValueData
‘Set Acceleration.Level to Full
objReg.SetDWORDValue HKEY_LOCAL_MACHINE,RIGHT(RegValueData, 82),”Acceleration.Level”,0
wscript.sleep 3000
End Function
Function Reboot
Msgbox “Operation Complete.”
End Function