Jump to content
Sign in to follow this  
malka

checking if a specific device is exist in device manager - (Moved)

Recommended Posts

there is a device that sometimes is exist and sometimes not,

in my script I have to check if it exists if not to install it,

I know how yo open device manager but don't know how to check if it exists

thanks for your help!!!

Share this post


Link to post
Share on other sites

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Jos
Merge his posts?


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By ModemJunki
      The below code works (requires DevCon / Windows 7) - an array of device ID strings and their names comes - but it doesn't seem right to have to manipulate the drive letter strings in the array to "fix them up" as I have done.
      I need a list of all devices from Devcon (including non-present devices). At the end I will check for both present and non-present devices filtered against a list of known devices so I can see which are unplugged from the computer, but first I am building the list of all devices (plugged in or not).
      I am doing this workaround because DevCon outputs a list with ":" delimiter and if a filter driver (for some softwares) populates a drive letter they also have ":" in the description. See my comments in the "_RunDevcon" functions for where I do this manipulation.
      Is there a better/smarter way to do this?
      #include <String.au3> #include <Constants.au3> #include <Array.au3> Global $path_Devcon = @ScriptDir & '\devcon.exe' Global $aRemovable, $strRun, $foundall $foundall = _RunDevcon('"' & $path_Devcon & '" findall *'); the findall means we will see "non present devices" _ArrayDisplay($foundall, "List of devices and their PnP IDs", -1, 0, "", "", "Index|Device String|Device Name") ; Builds a device list using devcon ; by BugFix in 2009 and modified for this script Func _RunDevcon($strRun) Local $data, $dvcn = Run("cmd.exe", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) StdinWrite($dvcn, $strRun & @CRLF) StdinWrite($dvcn) While True $data &= StdoutRead($dvcn) If @error Then ExitLoop Sleep(25) WEnd Local $split = StringSplit($data, @LF) $data = '' For $i = 5 To $split[0] If StringStripWS($split[$i], 8) == '' Then ExitLoop $data &= $split[$i] Dim $devices[1][1] $devices = StringSplit($data, @CRLF) Next _ArrayDelete($devices, $devices[0] - 1); because the last line is "<number> matching device(s) found." $devices[0] = UBound($devices, 1) ;~ Some hoops to jump because Devcon returns a list of devices with ;~ a ":" in their descriptions and the delimiter between the devices is a ":"! $dvstr = _ArrayToString($devices, "'"); split array to string $dvstr_fixed = StringReplace($dvstr, ":", "!", 0, 2); replace the colons with something else $devarray = _String_Split($dvstr, "'", ":"); put all back into an array For $j = 1 To $devarray[0][0] - 1; we remove leading whitespace from second column If $devarray[$j][2] = "\" Then; now we fix the drive letters to have a colon again $Noblank = StringReplace($devarray[$j][1] & ":" & $devarray[$j][2], " ", "", 1) $devarray[$j][1] = $Noblank Else $Noblank = StringReplace($devarray[$j][1], " ", "", 1) $devarray[$j][1] = $Noblank EndIf Next _ArrayDeleteCol($devarray, 2); now we can delete the not-needed column _ArrayDelete($devarray, $devarray[0][0] - 1); we ended up with a blank at the end $devarray[0][0] = UBound($devarray, 1) Return $devarray EndFunc ;==>_RunDevcon ;~ Splits a string into an multidimensional array ;~ By wolf9228 in 2009 Func _String_Split($string, $delimiters1, $delimiters2) $Array1 = StringSplit($string, $delimiters1) Dim $MAXUBound = 0, $OutArray2[1][1] For $i = 1 To $Array1[0] Step 1 $OutArray = StringSplit($Array1[$i], $delimiters2) If $MAXUBound < $OutArray[0] Then ReDim $OutArray2[$i][$OutArray[0]] $MAXUBound = $OutArray[0] Else ReDim $OutArray2[$i][UBound($OutArray2, 2)] EndIf For $j = 1 To $OutArray[0] Step 1 $OutArray2[$i - 1][$j - 1] = $OutArray[$j] Next Next Return $OutArray2 EndFunc ;==>_String_Split ;~ Deletes column from array ;~ By PsaltyDS in 2008 Func _ArrayDeleteCol(ByRef $avWork, $iCol) If Not IsArray($avWork) Then Return SetError(1, 0, 0); Not an array If UBound($avWork, 0) <> 2 Then Return SetError(1, 1, 0); Not a 2D array If ($iCol < 0) Or ($iCol > (UBound($avWork, 2) - 1)) Then Return SetError(1, 2, 0); $iCol out of range If $iCol < UBound($avWork, 2) - 1 Then For $c = $iCol To UBound($avWork, 2) - 2 For $r = 0 To UBound($avWork) - 1 $avWork[$r][$c] = $avWork[$r][$c + 1] Next Next EndIf ReDim $avWork[UBound($avWork)][UBound($avWork, 2) - 1] Return 1 EndFunc ;==>_ArrayDeleteCol
×
×
  • Create New...