cliftonf has asked for the wisdom of the Perl Monks concerning the following question:
I have written a code to change the ip address of a Windows 2003 machine remotely.
The code works and I see the updates in the remote machine registry but after I reboot the box, the ip address comes back null.
It seems like there must be some routine I need to call to make the changes take affect like they do when you use control panel or netsh.
Here is the code, it works, but does not seem to stick ?
Really frustrated, been at this a long time, any help greatly appreciated.
local $SYSTEM_KEY = 'HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/'; local $TCP_KEY = 'Services/Tcpip/Parameters/Interfaces'; ########## Set IPs Masks and Gateways ########## for($i=0;$i<=$#nicids;$i++) { $tempkey = $SYSTEM_KEY.$TCP_KEY."\/".$nicids[$i]; $key = $Registry->Connect($machine, $tempkey); if (!$key) { print "ERROR: unable to connect to registry on machine $machine + for TCP_KEY \n$tempkey\n"; } $key->{'/IPAddress'} = $newnicips[$i]; $key->{'/SubnetMask'} = $newnicmasks[$i]; $key->{'/DefaultGateway'} = $newnicgateways[$i]; ####### Update the currently active location too ######### $tempkey = $SYSTEM_KEY."Services\/".$nicids[$i]."\/Parameters/Tcp +ip"; $key = $Registry->Connect($machine, $tempkey); if (!$key) { print "ERROR: unable to connect to registry on machine $machine + for TCP_KEY \n$tempkey\n"; } $key->{'/IPAddress'} = $newnicips[$i]; $key->{'/SubnetMask'} = $newnicmasks[$i]; $key->{'/DefaultGateway'} = $newnicgateways[$i]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Change Remote IP address using TieRegistry
by Anonymous Monk on Sep 22, 2009 at 21:37 UTC |