Jump to content
Sign in to follow this  
Doppio

Intel Proset/Wireless

Recommended Posts

Doppio

Good Morning.

I'm working on a utility to automate wireless configurations for my clients, but I found out that not all of them have the Intel wireless card.

I found several posts that show how to retrieve the system information, but I can't figure out how to use it in my code!

I have the following vb script that does what I need:

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter",,48)
    For Each objNIC in colItems
        pos3945 = InStr(objNIC.Name,"3945ABG")
        pos2200 = InStr(objNIC.Name,"2200BG")
        if pos3945 <> "0" or pos2200 <> "0" then
            ' \\ If an adapter exists, echo that it exists.
            'wscript.echo "Intel NIC Exists"
            IntelExists = "True"
        end if
    Next

Can someone help me convert this to Autoit?

Thanks in advance.

Share this post


Link to post
Share on other sites
MadBoy

Straight from AutoIt Scriptomatic. Edit those and you should get what you need <_<

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "AdapterType: " & $objItem.AdapterType & @CRLF
      $Output = $Output & "AdapterTypeId: " & $objItem.AdapterTypeId & @CRLF
      $Output = $Output & "AutoSense: " & $objItem.AutoSense & @CRLF
      $Output = $Output & "Availability: " & $objItem.Availability & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
      $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF
      $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
      $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
      $Output = $Output & "Index: " & $objItem.Index & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "Installed: " & $objItem.Installed & @CRLF
      $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
      $Output = $Output & "MACAddress: " & $objItem.MACAddress & @CRLF
      $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF
      $Output = $Output & "MaxNumberControlled: " & $objItem.MaxNumberControlled & @CRLF
      $Output = $Output & "MaxSpeed: " & $objItem.MaxSpeed & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "NetConnectionID: " & $objItem.NetConnectionID & @CRLF
      $Output = $Output & "NetConnectionStatus: " & $objItem.NetConnectionStatus & @CRLF
      $strNetworkAddresses = $objItem.NetworkAddresses(0)
      $Output = $Output & "NetworkAddresses: " & $strNetworkAddresses & @CRLF
      $Output = $Output & "PermanentAddress: " & $objItem.PermanentAddress & @CRLF
      $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
      $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
      $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
      $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
      $Output = $Output & "ProductName: " & $objItem.ProductName & @CRLF
      $Output = $Output & "ServiceName: " & $objItem.ServiceName & @CRLF
      $Output = $Output & "Speed: " & $objItem.Speed & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF
      $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
      $Output = $Output & "TimeOfLastReset: " & WMIDateStringToDate($objItem.TimeOfLastReset) & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NetworkAdapter" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":"

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
Doppio

I understand and have seen Scriptomatic in action, but how do I return true if the intel card exists?

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter",,48)
    For Each objNIC in colItems
        pos3945 = InStr(objNIC.Name,"3945ABG")
        pos2200 = InStr(objNIC.Name,"2200BG")
        if pos3945 <> "0" or pos2200 <> "0" then
            ' \\ If an adapter exists, echo that it exists.
            'wscript.echo "Intel NIC Exists"
            IntelExists = "True"
        end if
    Next

As you can see in this code if IntelExists = True I can continue executing the script.

Thanks.

Share this post


Link to post
Share on other sites
MadBoy

I understand and have seen Scriptomatic in action, but how do I return true if the intel card exists?

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
     Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter",,48)
     For Each objNIC in colItems
         pos3945 = InStr(objNIC.Name,"3945ABG")
         pos2200 = InStr(objNIC.Name,"2200BG")
         if pos3945 <> "0" or pos2200 <> "0" then
             ' \\ If an adapter exists, echo that it exists.
             'wscript.echo "Intel NIC Exists"
             IntelExists = "True"
         end if
     Next

As you can see in this code if IntelExists = True I can continue executing the script.

Thanks.

Well you run the first code i put on the page? Then at the Intel Card you stop for a moment. You notice that in product name, description, caption and few other places you can see what NIC it is.

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
       If StringInStr($objItem.Description, "Intel") Then 
           ; You have found out that the intel card is found
            MsgBox(0,"Test", "Intel card " & $objItem.Description & " was found")
        EndIf
    #cs
      $Output = $Output & "AdapterType: " & $objItem.AdapterType & @CRLF
      $Output = $Output & "AdapterTypeId: " & $objItem.AdapterTypeId & @CRLF
      $Output = $Output & "AutoSense: " & $objItem.AutoSense & @CRLF
      $Output = $Output & "Availability: " & $objItem.Availability & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
      $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF
      $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
      $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
      $Output = $Output & "Index: " & $objItem.Index & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "Installed: " & $objItem.Installed & @CRLF
      $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
      $Output = $Output & "MACAddress: " & $objItem.MACAddress & @CRLF
      $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF
      $Output = $Output & "MaxNumberControlled: " & $objItem.MaxNumberControlled & @CRLF
      $Output = $Output & "MaxSpeed: " & $objItem.MaxSpeed & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "NetConnectionID: " & $objItem.NetConnectionID & @CRLF
      $Output = $Output & "NetConnectionStatus: " & $objItem.NetConnectionStatus & @CRLF
      $strNetworkAddresses = $objItem.NetworkAddresses(0)
      $Output = $Output & "NetworkAddresses: " & $strNetworkAddresses & @CRLF
      $Output = $Output & "PermanentAddress: " & $objItem.PermanentAddress & @CRLF
      $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
      $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
      $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
      $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
      $Output = $Output & "ProductName: " & $objItem.ProductName & @CRLF
      $Output = $Output & "ServiceName: " & $objItem.ServiceName & @CRLF
      $Output = $Output & "Speed: " & $objItem.Speed & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF
      $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
      $Output = $Output & "TimeOfLastReset: " & WMIDateStringToDate($objItem.TimeOfLastReset) & @CRLF
    #ce
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NetworkAdapter" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
MadBoy

This is exactly what you need (of course you can clean some of it but i am too lazy to do it for you) <_<

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
       If StringInStr($objItem.Name, "3945ABG") OR StringInStr($objItem.Name, "2200BG") Then
            $IntelExists = "True"
            ExitLoop
        EndIf
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NetworkAdapter" )
Endif

If $IntelExists = "True" Then
    ; Do Something what you want :) 
EndIf

Edit: Cleaned my code anyway :)

Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
Doppio

Thanks!.

I modified the following, but yours looks much cleaner.

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM WiFi_AdapterDevice", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
       $pos3945 = StringInstr($objItem.Description,"3945ABG")
       $pos2200 = StringInstr($objItem.Description,"2200BG")
            if $pos3945 <> "0" or $pos2200 <> "0" then
            $IntelExists = "True"
        Else
            $IntelExists = "False"
            endif

$Output = $Output & "Intel Card: " & $IntelExists & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "WiFi_AdapterDevice" )
Endif

Share this post


Link to post
Share on other sites
ResNullius

My take on it, made into a function and checking for any connection with "Intel" & "Wireless" & "Connection" instead of specific adapter numbers:

If _IntelWirelessExists() Then
    MsgBox(0, "", "Intel Wireless Exists")
Else
    MsgBox(16, "", "NO Intel Wireless")
EndIf


Func _IntelWirelessExists()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost" 
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapter", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            If StringRegExp($objItem.Description, "(?i).*Intel.*Wireless.*Connection") Then Return True
        Next
        Return False
    Else
        MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_NetworkAdapter")
    EndIf
EndFunc   ;==>_IntelWirelessExists

Share this post


Link to post
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
Sign in to follow this  

×