ricky Posted December 4, 2008 Share Posted December 4, 2008 Hello, I make a script, but sometimes I have this error : Here is the script : expandcollapse popup#include <File.au3> #include <Array.au3> Const $_default = 5000; Temps d'attente par défaut ; Va rechercher le chemin dans la base de registre Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RAIDGuide Manager_is1", "InstallLocation") & "RAIDGuide.exe" Local $sFileIni = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RAIDGuide Manager_is1", "InstallLocation") & "atisConfig.ini" Local $sRun = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\run", "RAIDGuide") ; Supprime le raccourci pour RaidManager DeleteShortcut($sFile, @StartupDir) DeleteShortcut($sFile, @StartupCommonDir) ; Contrôle dans la base de registre si le client a activé au démarrage If $sRun <> "-" Then RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\run", "RAIDGuide", "REG_SZ", "-") CloseWindow() EndIf ; Teste si le fichier ini est présent If FileExists($sFileIni) Then $_ms = IniRead($sFileIni, "WaitingTime", "milliseconds", "") If $_ms == "" Then; Verifie qu'il y a bien une valeur sinon prend la valeur par défaut IniWrite($sFileIni, "WaitingTime", "milliseconds", $_default) $_ms = IniRead($sFileIni, "WaitingTime", "milliseconds", "") EndIf Else; Si c'est pas le cas, le créé avec la valeur par défaut IniWrite($sFileIni, "WaitingTime", "milliseconds", $_default) $_ms = $_default EndIf ; Ferme si le programme est déjà lancé CloseStart() Run($sFile, ""); Lance le programme qui gère l'easyRAID WinWaitActive("RAIDGuide Manager"); Attend que la fenêtre soit ouverte Sleep($_ms); Attend ce temps avant de continuer le script ControlSend("RAIDGuide Manager", "", "", "{F10}"); Envoie la touche F10 Exit; Quitte ce programme Func DeleteShortcut($SearchPath, $SearchDir) Local $search = FileFindFirstFile($SearchDir & "\*.lnk") If $search = -1 Then Return While 1 Local $iFile = FileFindNextFile($search) If @error Then Return Local $aParams = FileGetShortcut($SearchDir & "\" & $iFile) If StringInStr($aParams[0], $SearchPath) Then FileDelete($SearchDir & "\" & $iFile) CloseWindow() EndIf WEnd FileClose($search) EndFunc ;==>DeleteShortcut Func CloseStart() Do $PID = ProcessExists("RAIDGuide.exe") If $PID Then ProcessClose($PID) Sleep(1000) $PID = ProcessExists("RAIDGuide.exe") Until $PID = 0 EndFunc ;==>CloseStart Func CloseWindow() $i = 0 Do $PID = ProcessExists("RAIDGuide.exe") If $PID Then ProcessClose($PID) Return Else $i = $i + 1 Sleep(2000) EndIf Until $i = 4 EndFunc ;==>CloseWindow Somebody can help me to correct this error? If somebody see how to optimise this code, please write a little response. Thanks in advance, best Regards Ricky Link to comment Share on other sites More sharing options...
AzKay Posted December 4, 2008 Share Posted December 4, 2008 Run the code through SciTE # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
ricky Posted December 4, 2008 Author Share Posted December 4, 2008 (edited) I'm sorry, but I don't understand. Edit : I run with SciTE, with no error or I don't run correctly. But usually I run autoitWrapper Edited December 4, 2008 by ricky03 Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 4, 2008 Share Posted December 4, 2008 I'm sorry, but I don't understand. Edit : I run with SciTE, with no error or I don't run correctly. But usually I run autoitWrapper You should run Tidy (Ctrl-T) and Syntax Check (Ctrl-F5), then if possible run the script from SciTE (F5) so you can see specific errors in the console pane. In this case, you will probably find that some .lnk file you are getting from FileFindNextFile() is not a valid link file, so FileGetShortcut() does not return an array for it. Just add some error handling: Local $aParams = FileGetShortcut($SearchDir & "\" & $iFile) If @error Then MsgBox(16, "Error", "Error getting shortcut info from: " & $SearchDir & "\" & $iFile) Else If StringInStr($aParams[0], $SearchPath) Then FileDelete($SearchDir & "\" & $iFile) CloseWindow() EndIf EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
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