Hi,
I need to set an IP address + Subnet musk
On this machine the service: "Remote Registry Service" is Disable.
Is there any alternative command line utility (not netsh.exe - that
need this service)
that can do this job ?
Any help on this would be great
Thanks
Ran
How about a vbscript? I placed this code into a windows form (vb6) in
order to allow an employee to set a static on his laptop in one
location, then back to receiving a dhcp lease in another location.
Here's the code that will set the static information. Just place this
into a text file and save it with a vbs extension (ie: changeip.vbs).
Watch for word wrap.
'----------BEGIN STATIC IP CODE----------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where
IPEnabled=TRUE")
strIPAddress = Array("192.168.1.50") 'PLACE YOUR STATIC IP HERE
strSubnetMask = Array("255.255.255.0") 'PLACE YOUR SUBNETMASK HERE
strGateway = Array("192.168.1.250") 'PLACE YOUR DEFAULT GATEWAY HERE
strGatewaymetric = Array(1)
arrDNSServers = Array("192.168.1.10", "205.171.1.11") 'PLACE DNS SERVERS
HERE
For Each objNetAdapter In colNetAdapters
'USE BELOW TO SET WINS SERVERS. REMOVE IF NOT NEEDED.
strPrimaryServer = "192.168.1.15" 'WINS SERVER ONE
strSecondaryServer = "192.168.3.15" 'WINS SERVER TWO
objNetAdapter.SetWINSServer strPrimaryServer, strSecondaryServer
'USE ABOVE TO SET WINS SERVERS. REMOVE IF NOT NEEDED.
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNSServers = objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
Next
'----------END STATIC IP CODE----------
You can set the adapter back to get a lease with this VB Script. Once
again, save it to a text file and name it with a vbs extension. I see
that I set the DNS addresses in this. You may just try removing that
line if you want to get your DNS servers from the DHCP server (see
in-line comments).
'----------BEGIN DHCP LEASE CODE----------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where
IPEnabled=TRUE")
'REMOVE LINE BELOW TO REMOVE STATIC DNS ENTRIES
arrDNSServers = Array("192.168.1.10", "192.168.1.11")
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
'REMOVE LINE BELOW TO REMOVE STATIC DNS ENTRIES
errDNSServers = objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
Next
'----------END DHCP LEASE CODE----------
Once you have your vbs saved, you can run it via a command line just as
you would any other program.
HTH,
Jim