The Glimmerman Posted October 29, 2006 Posted October 29, 2006 Hello all. I've got this script from some forum. (MSFN.org)And I've asked the maker of this script why this is not working for me.He said that it is working. I looked at his script 24/7 and now I'm getting nightmares. So I hope one of u can make me a happy man. What it does. It searches for inf files in a directory structure. In my case inf files. For a lot of drivers. A total of 1.4GbWhen it finds an inf file it's then execute by an API (setupapi.dll - SetupCopyOemInf)When I execute this script I get values$DirOutput and $DirOutputOnce Get values but $DirSplit is empty. I think its going wrong there but why I really don't know.These 2 lines are added by me.$path_to_drivers = "C:\Drivers"$DirOutputOnce = 0To get the script to work. He said it should work. But it doesn't. I hope someone can help me.Thx in advance.expandcollapse popup#NoTrayIcon #include <Constants.au3> Opt("ExpandEnvStrings", 1) Opt("WinWaitDelay", 0) Opt("WinTitleMatchMode",2) $path_to_drivers = "C:\Drivers" $DirOutputOnce = 0 $DirOutput = Run(@ComSpec & " /c DIR /A:D /S " & $path_to_drivers, '', @SW_HIDE, 2) While 1 $DirData = StdoutRead($DirOutput) If @error Then ExitLoop If $DirData Then $DirOutputOnce &= $DirData Else Sleep(10) EndIf WEnd $DirOutputOnce = StringStripWS($DirOutputOnce, 3) ; Split output into array $DirSplit = StringSplit($DirOutputOnce, @CRLF, 1) $NrCopiedInfs = 0 For $i = 1 To $DirSplit[0] If StringInStr($DirSplit[$i], $path_to_drivers) Then $registrystring = StringSplit($DirSplit[$i], ": ", 1) If $registrystring[0] = 2 Then; Testing amount of elements in array, if more then 2 Exits If StringInStr($registrystring[2], $path_to_drivers) Then; Making sure that Drivers path exists in string $drivers_directory = $registrystring[2] $search_ini = FileFindFirstFile($drivers_directory & "\*.inf") If $search_ini = -1 Then Else $dll_exe = DllOpen("setupapi.dll") While 1 $search_file = FileFindNextFile($search_ini) $full_path_to_inf = $drivers_directory & "\" & $search_file If @error Then ExitLoop $dll_result = DllCall($dll_exe, "int", "SetupCopyOEMInf", "str", $full_path_to_inf, "str", "", "int", 1, "int", 8, "str", "", "int", 0, "int", 0, "str", "") $NrCopiedInfs = $NrCopiedInfs + 1 ; If $logging_option = "Advanced" Then ; If @error = 0 Then ; _AddLineBox("Inf integration passed: " & $drivers_directory & "\" & $search_file) ; $NrCopiedInfs = $NrCopiedInfs + 1 ; ElseIf @error = 1 Then ; _AddLineBox("Inf integration failed: " & $drivers_directory & "\" & $search_file) ; ElseIf @error = 2 Or @error = 3 Then ; _AddLineBox("Unknown return type or Function not found in DLL. Tell author about it!") ; EndIf ; EndIf WEnd DllClose($dll_exe) EndIf FileClose($search_ini) EndIf EndIf EndIf Next If $NrCopiedInfs = 1 Then MsgBox(4096, "", "SetupCopyOemInf method completed. " & $NrCopiedInfs & " driver was integrated.",5) If $NrCopiedInfs = 0 Then MsgBox(4096, "", "SetupCopyOemInf method completed. No drivers were integrated.",5) If $NrCopiedInfs <> 0 And $NrCopiedInfs <> 1 Then MsgBox(4096, "", "SetupCopyOemInf method completed. " & $NrCopiedInfs & " drivers were integrated.",5)
PaulIA Posted October 29, 2006 Posted October 29, 2006 I ran the following script and $DirSplit is not empty. The only change from yours is that I properly set $DirOutputOnce to an empty string, but that isn't the problem. $path_to_drivers = "C:\Windows\System32" $DirOutputOnce = "" $DirOutput = Run(@ComSpec & " /c DIR /A:D /S " & $path_to_drivers, '', @SW_HIDE, 2) While 1 $DirData = StdoutRead($DirOutput) If @error Then ExitLoop If $DirData Then $DirOutputOnce &= $DirData Else Sleep(10) EndIf WEnd $DirOutputOnce = StringStripWS($DirOutputOnce, 3) $DirSplit = StringSplit($DirOutputOnce, @CRLF, 1) For $i = 1 To $DirSplit[0] ConsoleWrite($DirSplit[$i] & @CR) next Debug your code by using the SciTE editor and writing debug information to the console at various points in your program so you can track down the problem. Auto3Lib: A library of over 1200 functions for AutoIt
The Glimmerman Posted October 29, 2006 Author Posted October 29, 2006 @PaulIAPaulIA your'e the best. I found the error and the script is working like a charm. I use the wrong delimiter in :$registrystring = StringSplit($DirSplit[$i], ": ", 1)should be :$registrystring = StringSplit($DirSplit[$i], "of ", 1)Thx m8
PaulIA Posted October 29, 2006 Posted October 29, 2006 Your welcome. Glad I could help. Auto3Lib: A library of over 1200 functions for AutoIt
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now