Balragh Posted June 17, 2024 Posted June 17, 2024 Hello everyone, this is my first post here, I'm trying to create a script that search for a specific file inside a directory here "HpFirmwareUpdRec.exe" inside C:/SWSetup. something like : C:/SWSetup -> SPXXXX ->SPXXXX ->SPXXXX "HpFirmwareUpdRec.exe" I tried to use _FileListToArrayRec but I getting only errors 😕 Here is what I have so far : $model = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemProductName") $versionOs = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DisplayVersion") $arrayexe = _FileListToArray(@WorkingDir & "\Driver\" & $model & "\BIOS" , "*.exe", 1, True) For $i = 1 To $arrayexe[0] ShellExecuteWait($arrayexe[$i], "/s /e") Next Sleep(3000) $arraybios = _FileListToArrayRec(@"C:\SWSetup" , "HpFirmwareUpdRec.exe",$FLTAR_FILESFOLDERS, $FLTAR_RECUR) For $i = 1 To $arraybios[0] ShellExecuteWait($arraybios[$i], "-s -r") Next MsgBox($MB_SYSTEMMODAL, "", "fin du script") Would you have any suggestion on what I can do to
ioa747 Posted June 17, 2024 Posted June 17, 2024 (edited) try this first and see if everything is as you expect $model = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemProductName") ConsoleWrite("$model=" & $model & @CRLF) $versionOs = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DisplayVersion") ConsoleWrite("$versionOs=" & $versionOs & @CRLF) ConsoleWrite("" & @WorkingDir & "\Driver\" & $model & "\BIOS" & @CRLF) in this line one @ is too many $arraybios = _FileListToArrayRec(@"C:\SWSetup" , "HpFirmwareUpdRec.exe",$FLTAR_FILESFOLDERS, $FLTAR_RECUR) Edit: all together #include <FileConstants.au3> #include <File.au3> $model = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemProductName") ConsoleWrite("$model=" & $model & @CRLF) $versionOs = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DisplayVersion") ConsoleWrite("$versionOs=" & $versionOs & @CRLF) FileChangeDir(@ScriptDir) ; now @WorkingDir = @ScriptDir ConsoleWrite("" & @WorkingDir & "\Driver\" & $model & "\BIOS" & @CRLF) $arrayexe = _FileListToArray(@WorkingDir & "\Driver\" & $model & "\BIOS", "*.exe", 1, True) If @error Then ConsoleWrite("Ooops! No files found" & @CRLF) Else For $i = 1 To $arrayexe[0] ;~ ShellExecuteWait($arrayexe[$i], "/s /e") ConsoleWrite("ShellExecuteWait -> " & $arrayexe[$i] & @CRLF) Next EndIf Sleep(3000) ; no need $FLTAR_FILESFOLDERS since HpFirmwareUpdRec.exe is file $arraybios = _FileListToArrayRec("C:\SWSetup", "HpFirmwareUpdRec.exe", $FLTAR_FILES, $FLTAR_RECUR) If @error Then ConsoleWrite("Ooops! No files found" & @CRLF) Else For $i = 1 To $arraybios[0] ;~ ShellExecuteWait( "C:\SWSetup\" & $arraybios[$i], "-s -r") ; need "C:\SWSetup\" or $FLTAR_FULLPATH in _FileListToArrayRec ConsoleWrite("ShellExecuteWait -> " & "C:\SWSetup\" & $arraybios[$i] & @CRLF) Next ;~ MsgBox($MB_SYSTEMMODAL, "", "fin du script") EndIf Edited June 17, 2024 by ioa747 Edit I know that I know nothing
Balragh Posted June 17, 2024 Author Posted June 17, 2024 Hello, Thanks a lot, the thing that was blocking was the missing ShellExecuteWait( "C:\SWSetup\" & . Now it finally installs that BIOS update but .. at the end of the script, every folder and subfolder are being opened not just the HpFirmwareUpdRec.exe. Would there be a way to prevent that ? The complete portion of script I have is this : #RequireAdmin #include <MsgBoxConstants.au3> #include <File.au3> $model = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemProductName") $versionOs = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DisplayVersion") $arrayexe = _FileListToArray(@WorkingDir & "\Driver\" & $model & "\BIOS" , "*.exe", 1, True) For $i = 1 To $arrayexe[0] ShellExecuteWait($arrayexe[$i], "/s /e") Next Sleep(3000) $arraybios = _FileListToArrayRec("C:\SWSetup" , "HpFirmwareUpdRec.exe",$FLTAR_FILESFOLDERS, $FLTAR_RECUR) For $i = 1 To $arraybios[0] ShellExecuteWait("C:\SWSetup\" & $arraybios[$i], "-s -r") Next MsgBox($MB_SYSTEMMODAL, "", "fin du script")
Solution ioa747 Posted June 17, 2024 Solution Posted June 17, 2024 (edited) when you run the script above (all together) what does the ConsoleWrite tell you? ConsoleWrite("ShellExecuteWait -> " & $arrayexe[$i] & @CRLF) ConsoleWrite("ShellExecuteWait -> " & "C:\SWSetup\" & $arraybios[$i] & @CRLF) wants better filtering in the results e.g. no need $FLTAR_FILESFOLDERS since HpFirmwareUpdRec.exe is file which function opens the extra folders? _FileListToArray(@WorkingDir & "\Driver\" & $model & "\BIOS", "*.exe", 1, True) or _FileListToArrayRec("C:\SWSetup", "HpFirmwareUpdRec.exe", $FLTAR_FILES, $FLTAR_RECUR) Edited June 17, 2024 by ioa747 I know that I know nothing
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