Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Win32 Detect Active Nic and change IP

by Marza (Vicar)
on Aug 26, 2009 at 21:11 UTC ( #791460=perlquestion: print w/replies, xml ) Need Help??

Marza has asked for the wisdom of the Perl Monks concerning the following question:


I have been tasked with re-iping a data center for a move. You would think we should use dhcp but that is another story.

I have been looking at tieregistry but there are issues. Many machines have multiple nics(physical and virtual), some people changed the name "Local Area Connection" to something else.

There is the batch file approach but they don't want to install things.

Netsh can do the job but I have never been able to get the -r option to work. Keep getting unknown commands. psexec feeding the command will work but since it's a new ip range, it hangs the computer which means a 5 minute timeout.

Anybody know of a way to detect the active NIC? Once that is identified; it would be possible to locate the GUID entry in the registry and make the appropriate changes.

So far not much luck in my searching.

Right now I am considering taskscheduler with netsh and a shutdown command.


Replies are listed 'Best First'.
Re: Win32 Detect Active Nic and change IP
by youlose (Scribe) on Aug 27, 2009 at 07:23 UTC
    `netsh interface show interface`
    Resulting table with active interfaces data
    `netsh interfase ip set address bla-bla-bla`
Re: Win32 Detect Active Nic and change IP
by youlose (Scribe) on Aug 30, 2009 at 20:36 UTC
    You can use WMI through Win32::OLE for this task also
Re: Win32 Detect Active Nic and change IP
by Anonymous Monk on Aug 27, 2009 at 03:11 UTC
    If they can't install a batch file, how can you do anything?

    Try ipconfig

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://791460]
Approved by AnomalousMonk
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-01-23 05:48 GMT
Find Nodes?
    Voting Booth?