http://qs321.pair.com?node_id=791460

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

Greetings,

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.

Thanks!

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