You can set the network settings with netsh via a Net::Telnet session. I use this script along side a form that feeds it the required info. You could try the registry with Win32::TieRegistry. Hope you can pull some insight out of this example where I set the wins/dns via telnet... then we login via Win32 Remote Term and just run the bat file that executes the netsh static ip line and cleans the .bat off the desktop. I suppose you could execute it the netsh static if you were on the same subnet... but we are not, and telnet session closes before the command executes.
#!/perl/bin/perl use Net::Telnet; use CGI qw(:all); #my @rv=`serverconfig.pl $host $newip $password $hostname $netmask + # $gateway $dbdns1 $dbdns2 $dbwins1 $dbwins2`; my $username = "administrator"; my $host = "$ARGV[0]"; my $newip = "$ARGV[1]"; my $password = "$ARGV[2]"; my $servername = "$ARGV[3]"; my $netmask = "$ARGV[4]"; my $gateway = "$ARGV[5]"; my $dns1 = "$ARGV[6]"; my $dns2 = "$ARGV[7]"; my $wins1 = "$ARGV[8]"; my $wins2 = "$ARGV[9]"; my $t = Net::Telnet->new(Timeout =>5, Prompt=>'/\>/'); my $ok; $ok = $t->open($host); $ok = $t->login($username, $password); $ok = $t->cmd("netsh interface ip add dns \"Production LAN\" $dns1 in +dex=1"); sleep 2; $ok = $t->cmd("netsh interface ip add dns \"Production LAN\" $dns2 in +dex=2"); sleep 2; $ok = $t->cmd("netsh interface ip delete wins \"Production LAN\" all" +); sleep 2; $ok = $t->cmd("netsh interface ip add wins \"Production LAN\" $wins1 +index=1"); sleep 2; $ok = $t->cmd("netsh interface ip add wins \"Production LAN\" $wins2 +index=2"); sleep 2; $ok = $t->cmd("echo netsh interface ip set address \"Production LAN\" +static $newip $netmask $gateway 1 > c:\\\"Documents and Settings\"\\A +dministrator\\Desktop\\set_ip.bat"); sleep 2; $ok = $t->cmd("echo erase set_ip.bat >> c:\\\"Documents and Settings\" +\\Administrator\\Desktop\\set_ip.bat"); sleep 2; $ok = $t->cmd("exit"); sleep 1; $t->close; print redirect("admin.cgi?query=$args");
JamesNC Update... FYI, You don't ever need to reboot a machine when you change it's IP address... You will only have to do that if you change the hostname.

In reply to Re: Change IP-address and computer name on Win32 by JamesNC
in thread Change IP-address and computer name on Win32 by primus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.