Jump to content

Link NIC-device to "Local Area Connection"


Recommended Posts

Hello All,

I wrote the following code this morning:

#include <Constants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#Include <String.au3>
#Include <Array.au3>

; Hide the damn Tray-Icon that nobody needs
#NoTrayIcon

Global $s_ini_file = "PostInstall.ini"
Global $s_ini_sections = IniReadSectionNames($s_ini_file)

; Function _GetNICdevices to find all NICs within the local system
; ==============================================================================================
$output = ""

; Create the arrrays $HWIDsToProbe[10] and $VMIDsToProbe[10] to contain the relevant values from the Ini-File
Dim $HWIDsToProbe[10]
For $i = 0 to 9 
    _ArrayInsert($HWIDsToProbe, $i, IniRead($s_ini_file, "Settings", "HW-NIC-" & $i, ""))
Next

Dim $VMIDsToProbe[10]
For $i = 0 to 9 
    _ArrayInsert($VMIDsToProbe, $i, IniRead($s_ini_file, "Settings", "VM-NIC-" & $i, ""))
Next

;_ArrayDisplay($HWIDsToProbe, "Array of NICstrings")
;_ArrayDisplay($VMIDsToProbe, "Array of NICstrings")

; Execute the command "devcon find PCI\Ven*"
For $i = 0 To UBound($HWIDsToProbe) - 2
    $PID = Run(@ComSpec & " /c " & "devcon find PCI\Ven* | find " & '"' & $HWIDsToProbe[$i] & '"', "", @SW_HIDE, $STDOUT_CHILD)
    While 1
        $line = StdoutRead($PID)
        If @error Then ExitLoop
        $output &= $line
    Wend
Next

; Execute the command "devcon find @ROOT\VMware*"
For $i = 0 To UBound($VMIDsToProbe) - 2
    $PID = Run(@ComSpec & " /c " & "devcon find @ROOT\VMware* | find " & '"' & $VMIDsToProbe[$i] & '"', "", @SW_HIDE, $STDOUT_CHILD)
    While 1
        $line = StdoutRead($PID)
        If @error Then ExitLoop
        $output &= $line
    Wend
Next

; Show results in a Message Box 
MsgBox(0, "NICs in this System:", $output)oÝ÷ Ù8^xW¥¢,)¶¬jëh×6[Settings]

; Be careful when enhancing; none of the strings must occur in more than one device description!!!
; Strings to be found in the Decivenames of the local Machine's NICs - please change only with greate care!!!
HW-NIC-0=PRO/100
HW-NIC-1=Broadcom
HW-NIC-2=IBM
HW-NIC-3=3Com
HW-NIC-4=SX
HW-NIC-5=Realtek
HW-NIC-6=
HW-NIC-7=
HW-NIC-8=
HW-NIC-9=

; Strings to be found in the Decivenames of the local VM's NICs - please change only with greate care!!!
VM-NIC-0=VMnet1
VM-NIC-1=VMnet2
VM-NIC-2=VMnet3
VM-NIC-3=VMnet4
VM-NIC-4=VMnet5
VM-NIC-5=VMnet6
VM-NIC-6=VMnet7
VM-NIC-7=VMnet8
VM-NIC-8=
VM-NIC-9=

Now I need a way to assign the found (emulated) hardware devices to the right "Local Area Connection". Does anybody have an idea howto accomplish this?

Thank you very much for eventually upcoming efforts,

Ragards,

Chris

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...