Jump to content

AntonioGNAL

Active Members
  • Posts

    26
  • Joined

  • Last visited

AntonioGNAL's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Oh my God!!! Thanks, i was so obsessed about the conditions i didn't even think about that.
  2. Hi Paramjeet, Thanks for your answer. I already have the includes and other variables in the code, i just didn't write everything because it would take too much space. I did something i was afraid might work and it did... instead of exporting the key: HKEY_CURRENT_USERSoftwareHewlett-PackardHP Print SettingsUbicación predeterminadaTarget History I exported the key: HKEY_CURRENT_USERSoftwareHewlett-PackardHP Print Settings And the reg file automatically appeared when i executed the program. So there's something wrong with that key name which i'm unable to find. I also have an issue here: Local $removeFile $removeFile = FileDelete($THRegBkup) If $removeFile Then _FileWriteLog($logHandler, "INFORMATION: File " & $THRegBkup & " deleted." Else _FileWriteLog($logHandler, "WARNING: File " & $THRegBkup & " not deleted or it does not exist." EndIf I don't know why, but i get this error: It's strange because in the function description i saw a really similar code: ; Delete the temporary file. Local $iDelete = FileDelete($sFilePath) ; Display a message of whether the file was deleted. If $iDelete Then MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.") Else MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.") EndIf Any ideas?
  3. Hi guys, I've been trying to create a registry key export for a while, but i'm hitting my head against a wall here. I've tried a huge amount of combinations for both: ShellExecuteWait & RunWait commands, but they never complete the task. ;This is the reg key Global $targetHistory = "HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History" RegeditTH($logHandler, $regBackup, $targetHistory) Func RegeditTH($logHandler, $regBackup, $targetHistory) Local $THRegBkup = $regBackup & "ExportTH.bat" Local $THRegHandler Local $removeFile _FileWriteLog($logHandler, "INFORMATION: ExportTH.bat storage directory = " & $regBackup & "." & @CRLF) ; Create a file to write registry keys to. If Not _FileCreate($THRegBkup) Then ; Error flags: ; 1 - Error opening specified file ; 2 - File could not be written to ; [OPTIONAL] Display a pop-up message for notification, error creating the file ;MsgBox($MB_SYSTEMMODAL, "Error", " Error reating reg file. Error Code:" & @error & ".") _FileWriteLog($logHandler, "WARNING: Registry export file not created." & @CRLF) Else $THRegHandler = FileOpen ($THRegBkup ,$FO_APPEND) If $THRegHandler <> -1 Then _FileWriteLog($logHandler, "INFORMATION: Performing registry backup for Target History keys." & @CRLF) FileWrite($THRegHandler, "@echo off" & @CRLF) ;FileWrite($THRegHandler, "regedit.exe /e " & $regBackup & "TargetHistory.reg " & '"HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History"' & @CRLF) FileWrite($THRegHandler, "Reg export " & '"HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History" ' & $regBackup & "TargetHistory.reg " & "/y" & @CRLF) FileWrite($THRegHandler, "dir " & $regBackup & @CRLF) FileWrite($THRegHandler, "dir " & $regBackup & " >> " & $regBackup & "dir.txt" & @CRLF) FileWrite($THRegHandler, "pause" & @CRLF) FileWrite($THRegHandler, "exit /B" & @CRLF) FileWrite($THRegHandler, "exit" & @CRLF) FileClose($THRegHandler) ;RunWait(@ComSpec & " /k " & "regedit.exe /e " & $regBackup & "TargetHistory2.reg " & $targetHistory) ;ShellExecuteWait(@ComSpec , "/k regedit.exe /e " & $regBackup & "TargetHistory.reg " & $targetHistory) ;ShellExecuteWait(@ComSpec & " /c " & $THRegBkup, @SW_HIDE) RunWait(@ComSpec & " /c " & $THRegBkup) ; Error Flag is set to non-zero in case of failure If @error <> 0 Then _FileWriteLog($logHandler, "ERROR: Registry export failed." & @CRLF) Else _FileWriteLog($logHandler, "WARNING: ExportTH.bat file could not be opened." & @CRLF) EndIf $removeFile = FileDelete($THRegBkup) If $removeFile Then _FileWriteLog($logHandler, "INFORMATION: File " & $THRegBkup & " deleted." Else _FileWriteLog($logHandler, "WARNING: File " & $THRegBkup & " not deleted or it does not exist." EndIf EndIf ; Close the handle returned by FileOpen. FileClose($THRegHandler) EndFunc This is the function i'm using for the call. Since i was not going anywhere with the AutoIt direct executions, i even tried creating a bat/cmd file with the command for a reg export to create the reg file i needed. However, even running the bat file is not working for me. I mean, the bat is executed, as you can see i created a couple of "dir" commands to be prompted and sent to a file. And they are showing up, but the registry export is never being executed. The best i could get was a message saying it was impossible to locate the key, but i know with 100% certainty the key exists in that path (because i'm creating and deleting it all the time). Can anyone point out any possible mistakes? Here you can see the error message in the CMD prompt: Thanks!
  4. This is the result form F5 (GO), i just learnt this existed when you mentioned it: >"C:Program Files (x86)AutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:UsersXXXXDesktopXXXXX_CPQ_v1003.au3" "C:UsersXXXXDesktopXXXXX_CPQ_v1003.au3" (180) : ==> Error parsing function call.: ShellExecuteWait((@ComSpec , "/k regedit.exe /e " & $regBackup & "TargetHistory.reg " & $targetHistory) ShellExecuteWait((@ComSpec , "/k regedit.exe /e " & $regBackup & "TargetHistory.reg " & $targetHistory^ ERROR >Exit code: 1 Time: 0.229 Edit: Now it's opening a cmd command prompt but it's empty. I think i don't understant how this works. I'll keep trying.
  5. I think you were right, i'll post the complete code when i correct it completely. But last changes seem to be working fine even with the original key name. Now the only part missing is the ShellExecuteWait, which is not performing the registry export. Do you see any mistakes here? Global $regBackup = "C:\PRef_BKUP\" Global $targetHistory = "HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History" $arrayTHsize <> 0 Then _FileWriteLog($logHandler, "DETECTED: Performing registry backup for Target History keys." & @CRLF) ShellExecuteWait("regedit.exe", "/e " & $regBackup & "TargetHistory.reg " & $targetHistory) EndIf I really appreciate your help... i'm not getting any in my company.
  6. I did something that might seem a bit stupid, but i got a different result. I renamed the key, manually again, to the name it is supposed to have and run the AutoIt script. This is the result in the log file: 2014-04-02 16:39:40 : ERROR LOG for CPQ 2014-04-02 16:39:40 : ***************** 2014-04-02 16:39:40 : User Logon: XXXXX 2014-04-02 16:39:40 : Computer Name: XXXXXX 2014-04-02 16:39:40 : Check for backup directory and create it if necessary. 2014-04-02 16:39:40 : Creating directory: C:PRef_BKUP 2014-04-02 16:39:40 : SUCCESS: C:PRef_BKUPcorrectly created. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 0. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 1. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 2. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 3. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 4. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 5. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 6. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 7. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 8. 2014-04-02 16:39:40 : PRINTER FOUND: Target value set to: 9. 2014-04-02 16:39:40 : INFORMATION: Target array size = 10. 2014-04-02 16:39:40 : INFORMATION: No more Target History keys found. Error: 0. 2014-04-02 16:39:40 : STEP: 10. 2014-04-02 16:39:40 : DETECTED: Performing registry backup for Target History keys. 2014-04-02 16:39:40 : Checking if there are any target values otherwise > Exit. 2014-04-02 16:39:40 : Removing printer references. Iteration: 0. 2014-04-02 16:39:40 : SUCCESS: Target History keys removed. Count: 0. 2014-04-02 16:39:40 : Removing printer references. Iteration: 1. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:40 : Removing printer references. Iteration: 2. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:40 : Removing printer references. Iteration: 3. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:40 : Removing printer references. Iteration: 4. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:40 : Removing printer references. Iteration: 5. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:40 : Removing printer references. Iteration: 6. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:40 : Removing printer references. Iteration: 7. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:40 : Removing printer references. Iteration: 8. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:40 : Removing printer references. Iteration: 9. 2014-04-02 16:39:40 : WARNING: Error removing Target History keys. Error: 1. 2014-04-02 16:39:42 : SUCCESS: Target History main key created. So the RegRead is working now (i replaced RegEnumKey with RedRead since it can use either). Additionally, the RegDelete also worked too, you can see it here: 2014-04-02 16:39:40 : SUCCESS: Target History keys removed. Count: 0. All the consecutive attempts are unnecesary, i need to rework the code there removing the loop. And the RegWrite did work too, creating the blank key as i needed. The only thing that did not work is the ShellExecuteWait for the registry export.
  7. Now i get an error which says: Error: Error parsing function call. Edit: Sorry, it's just because there's a ")" missing at the end of the first call. I'll try again. Edit2: I used this: Local $s1 = RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "Target0") ConsoleWrite('$s1:' & @CRLF & $s1 & @CRLF & '@error = ' & @error & @CRLF) Local $s2 = RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "TargetAge0") ConsoleWrite('$s2:' & @CRLF & $s2 & @CRLF & '@error = ' & @error & @CRLF) I execute it from a cmd command prompt, but i do not receive any message. (I mean i execute the .exe file from AutoIt) Edit3: Now i'm confused. I did this: Global $logPath = @WorkingDir & "\" & @ComputerName & "_Test_Reg.txt" _FileCreate($logPath) $logHandler = FileOpen ($logPath ,$FO_APPEND) Local $s1 = RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "Target0") ConsoleWrite('$s1:' & @CRLF & $s1 & @CRLF & '@error = ' & @error & @CRLF) Local $s2 = RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "TargetAge0") ConsoleWrite('$s2:' & @CRLF & $s2 & @CRLF & '@error = ' & @error & @CRLF) _FileWriteLog($logHandler, $s1 & @CRLF) _FileWriteLog($logHandler, $s2 & @CRLF) FileClose($logHandler) Exit And i received the correct values of the registry keys as a result in the log file: 2014-04-02 16:32:12 : <?xml version="1.0" encoding="UTF-8"?> <print-path><device><model>HP COLOR LASERJET CP4525dn</model><friendly-name></friendly-name><pdl><family>6</family><description>PostScript</description><version>Version 3010.107</version></pdl><pdl><family>3</family><description>PCL5</description><version>Version 5.00</version></pdl><pdl><family>47</family><description>PCL6</description><version>Version 3.0</version></pdl></device><device-configured>1</device-configured><discovery>9b60fae3-f3f1-4644-ac8e-60dfde5ecdd6</discovery><configurator>0a65ca79-f227-41aa-b4ec-17895f1495c1</configurator><features>dd026703-32ee-492b-b23f-ea60409cf779</features><attributes><attribute><name>Address</name><value-string>172.29.29.136</value-string></attribute><attribute><name>DV:ModelName</name><value-numeric>1</value-numeric></attribute><attribute><name>DV:PDL</name><value-numeric>1</value-numeric></attribute><attribute><name>DisplayString</name><value-string>PES28GASPC402</value-string></attribute><attribute><name>ExtBidiCacheFile</name><value-string>C:Program FilesHewlett-PackardHP Universal Printing172.29.29.136hp color laserjet cp4525dn.creg</value-string></attribute><attribute><name>ExternalBidiConfigData</name><value-string>http://172.18.184.83/hpmpl?extPrn=9</value-string></attribute><attribute><name>ExternalConfigType</name><value-numeric>3</value-numeric></attribute><attribute><name>IPAddress</name><value-string>172.29.29.136</value-string></attribute><attribute><name>LastQuery</name><value-numeric>262145</value-numeric></attribute><attribute><name>ManagedGroupXMLAdded</name><value-string>Remoto</value-string></attribute><attribute><name>ManuallyEntered</name><value-numeric>1</value-numeric></attribute><attribute><name>MystDisableDuplex</name><value-numeric>0</value-numeric></attribute><attribute><name>MystDisableJobRetention</name><value-numeric>0</value-numeric></attribute><attribute><name>MystIsColorDevice</name><value-numeric>1</value-numeric></attribute><attribute><name>MystPSLanguageLevel</name><value-numeric>3</value-numeric></attribute><attribute><name>Nickname</name><value-string>PES28GASPC402</value-string></attribute><attribute><name>NoBidiQuery</name><value-numeric>28726991</value-numeric></attribute><attribute><name>Port</name><value-numeric>0</value-numeric></attribute><attribute><name>PrinterInfo</name><value-string>Modelo: HP COLOR LASERJET CP4525dn&#xa;Comentario: Serial Number :JPDTF4H2CC&#xa;Spain-MADRID-MAD Endesa Gas-Portico Planta 2-2 - Remoto</value-string></attribute><attribute><name>ValidateDevice</name><value-numeric>1</value-numeric></attribute></attributes></print-path> 2014-04-02 16:32:12 : 0
  8. I'm not getting any output. :-/ I have a batch file with a similar purpose which in essence does this: The curious thing about it... is if i comment the lines for the reg query and the reg export, it removes and creates the registry key correctly. However, if i leave those lines uncommented, i get an error saying the system was unable to find the specified registry key or value.
  9. Yes i tried that too, but i get the same error. I even added that exact line you wrote to have a reference (since that key exists too). I changed the code to check for a specific key, instead of trying to capture the folder main key. Here you can see a sample image of the keys: '> So i reworked the code including an array for possible targets, since that key goes like this: Target0, Target1, Target2... TargetN. ; Declaration of variables Global $regBackup = "C:\PRef_BKUP\" Global $userLogon = @UserName Global $comName = @ComputerName Global $logPath = @WorkingDir & "\" & $comName & "_CPQ_Log.txt" Global $errFlag = 1 Global $arrayTHsize = 0 Global $arrayTH[10] $arrayTH[0]=0 $arrayTH[1]=0 $arrayTH[2]=0 $arrayTH[3]=0 $arrayTH[4]=0 $arrayTH[5]=0 $arrayTH[6]=0 $arrayTH[7]=0 $arrayTH[8]=0 $arrayTH[9]=0 ; Create a log file to write data to. If Not _FileCreate($logPath) Then ; Error flags: ; 1 - Error opening specified file ; 2 - File could not be written to ; [OPTIONAL] Display a pop-up message for notification, error creating the log ;MsgBox($MB_SYSTEMMODAL, "Error", " Error Creating/Resetting log file. Error Code:" & @error & ".") EndIf ; Open the log file for writing (append to the end of a file) and store the handle to a variable. $logHandler = FileOpen ($logPath ,$FO_APPEND) _FileWriteLog($logHandler, "ERROR LOG for CPQ" & @CRLF) _FileWriteLog($logHandler, "*****************" & @CRLF) _FileWriteLog($logHandler, "User Logon: " & $userLogon & @CRLF) _FileWriteLog($logHandler, "Computer Name: " & $comName & @CRLF) _FileWriteLog($logHandler, "Check for backup directory and create it if necessary." & @CRLF) If Not FileExists($regBackup) Then _FileWriteLog($logHandler, "Creating directory: " & $regBackup & @CRLF) $errFlag = DirCreate($regBackup) If $errFlag Then _FileWriteLog($logHandler, "SUCCESS: " & $regBackup & "correctly created." & @CRLF) Else _FileWriteLog($logHandler, "WARNING: " & "Error creating " & $regBackup & "directory" & @CRLF) EndIf EndIf ; New line for the SYSTEM key check RegEnumKey("HKEY_CURRENT_USER\SYSTEM",1) If @Error Then _FileWriteLog($logHandler, "HKCU_SYSTEM. Error: " & @error & "." & @CRLF) ; Locating Target0 to TargetN For $i = 0 To 10 RegEnumKey("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History", "Target" & $i) ; Alternatively use: RegRead function. If @Error Then ; Error flag: ; 1 = unable to open requested key ; 2 = unable to open requested main key ; 3 = unable to remote connect to the registry ; -1 = unable to open requested value ; -2 = value type not supported $arrayTHsize = $i _FileWriteLog($logHandler, "INFORMATION: Target array size = " & $arrayTHsize & "." & @CRLF) _FileWriteLog($logHandler, "INFORMATION: No more Target History keys found. Error: " & @error & "." & @CRLF) _FileWriteLog($logHandler, "STEP: " & $i & "." & @CRLF) $i = 10 Else $arrayTH[$i] = $i _FileWriteLog($logHandler, "PRINTER FOUND: Target value set to: " & $i & "." & @CRLF) EndIf Next If $arrayTHsize <> 0 Then _FileWriteLog($logHandler, "DETECTED: Performing registry backup for Target History keys." & @CRLF) ShellExecuteWait("regedit.exe", "/e " & $regBackup & "TargetHistory.reg HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History") EndIf ; If there is no Target History, no actions are required. Exit execution _FileWriteLog($logHandler, "Checking if there are any target values otherwise > Exit." & @CRLF) ;If $arrayTH[0] = 0 Then Exit Local $j = 0 While $j < $arrayTHsize _FileWriteLog($logHandler, "Removing printer references. Iteration: " & $j & "." & @CRLF) RegDelete("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History", "Target" & $j) If @Error Then ; Error Flags: ; 1 = unable to open requested key ; 2 = unable to open requested main key ; 3 = unable to remote connect to the registry ; -1 = unable to delete requested value ; -2 = unable to delete requested key/value _FileWriteLog($logHandler, "WARNING: Error removing Target History keys. Error: " & @error & "." & @CRLF) $j = $j + 1 Else _FileWriteLog($logHandler, "SUCCESS: Target History keys removed. Count: " & $j & "." & @CRLF) $j = $j + 1 EndIf WEnd Sleep(2000) RegWrite("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History", "") If @Error Then ; Error Flags: ; 1 = unable to open requested key ; 2 = unable to open requested main key ; 3 = unable to remote connect to the registry ; -1 = unable to open requested value ; -2 = value type not supported _FileWriteLog($logHandler, "WARNING: Error creating a blank Target History main key. Error: " & @error & "." & @CRLF) Else _FileWriteLog($logHandler, "SUCCESS: Target History main key created." & @CRLF) EndIf ; Close the handle returned by FileOpen. FileClose($logHandler) ; Close AutoIt Exit ; Finish! It is curious that the RegWrite function is not returning any error, it goes throught the "If" path where it says: "SUCCESS: Target History main key created." But it does not create anything. I removed the registry key manually to verify it. Could you tell me what's the "instance" the function reference indicates? I do not know what they are referring to.
  10. Hi guys, I'm trying to do what looks like a really simple task but, since i'm a total noob in programming, i'm having a lot of trouble. If someone could lend me a hand it would be really great. I'm trying to check if a registryfolder called "Target History" exists, then i remove the folder completely and create it again with no values inside. Here is the piece of code: Global $regBackup = "C:\PRef_BKUP\" Global $comName = @ComputerName Global $userLogon = @UserName Global $logPath = @WorkingDir & "\" & $comName & "_CPQ_Log.txt" Global $errFlag = 1 ; Create a log file to write data to. If Not _FileCreate($logPath) Then ; Error flags: ; 1 - Error opening specified file ; 2 - File could not be written to ; [OPTIONAL] Display a pop-up message for notification, error creating the log ;MsgBox($MB_SYSTEMMODAL, "Error", " Error Creating/Resetting log file. Error Code:" & @error & ".") EndIf ; Open the log file for writing (append to the end of a file) and store the handle to a variable. $logHandler = FileOpen ($logPath ,$FO_APPEND) _FileWriteLog($logHandler, "ERROR LOG for CPQ" & @CRLF) _FileWriteLog($logHandler, "*****************" & @CRLF) _FileWriteLog($logHandler, "User Logon: " & $userLogon & @CRLF) _FileWriteLog($logHandler, "Computer Name: " & $comName & @CRLF) ; Backup the registry key Target History to a file RegEnumKey("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History", "" ) ; Alternatively use: RegRead function. If @Error Then ; Error flag: ; 1 = unable to open requested key ; 2 = unable to open requested main key ; 3 = unable to remote connect to the registry ; -1 = unable to open requested value ; -2 = value type not supported _FileWriteLog($logHandler, "WARNING: Error searching for Target History keys. Error: " & @error & "." & @CRLF) Exit Else _FileWriteLog($logHandler, "DETECTED: Performing registry backup for Target History keys." & @CRLF) ShellExecuteWait("regedit.exe", "/e " & $regBackup & "TargetHistory.reg HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History") EndIf ; If there is no Target History, no actions are required. Exit execution _FileWriteLog($logHandler, "Checking if the registry backup is completed." & @CRLF) If Not FileExists($regBackup & "TargetHistory.reg") Then Exit _FileWriteLog($logHandler, "Removing printer references." & @CRLF) RegDelete("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History") If @Error Then ; Error Flags: ; 1 = unable to open requested key ; 2 = unable to open requested main key ; 3 = unable to remote connect to the registry ; -1 = unable to delete requested value ; -2 = unable to delete requested key/value _FileWriteLog($logHandler, "WARNING: Error removing Target History keys. Error: " & @error & "." & @CRLF) Else _FileWriteLog($logHandler, "SUCCESS: Target History keys removed. Error: " & @error & "." & @CRLF) EndIf Sleep(2000) RegWrite("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History") If @Error Then ; Error Flags: ; 1 = unable to open requested key ; 2 = unable to open requested main key ; 3 = unable to remote connect to the registry ; -1 = unable to open requested value ; -2 = value type not supported _FileWriteLog($logHandler, "WARNING: Error creating a blank Target History main key. Error: " & @error & "." & @CRLF) Else _FileWriteLog($logHandler, "SUCCESS: Target History main key created. Error: " & @error & "." & @CRLF) EndIf ; Close the handle returned by FileOpen. FileClose($logHandler) ; Close AutoIt Exit ; Finish! I made a lot of comments because it's easier for me to see what i'm doing every time. The registry functions are returning a -1 error flag: unable to open requested value. That's supposed to give me a hint, but i don't know what's wrong. I tried with an empty value and also with: RegEnumKey("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada", "Target History" ) But it seems i'm not getting the correct idea. Additionally, the ShellExecuteWait command is not doing anything at all. I've tried looking into the AutoIt help and googling, but i can't find the error in the code. Any suggestions? Thanks in advance!!!
  11. I found the problem. I can't use RunWait to stop services, but i can use it to exacute an external bat file who does. ; Patches Start! $Stop = @WorkingDir & "StopServices.bat" $Start = @WorkingDir & "StartServices.bat" ; Stop services to be able to copy the patch files RunWait($Stop) ;, @SW_HIDE) ; Copy the SafeCom patches to the main directory FileCopy(@WorkingDir & "scDevUtilLib.dll", "E:SafeComG3", 1) FileCopy(@WorkingDir & "scMoneyServer.exe", "E:SafeComG3", 1) FileCopy(@WorkingDir & "scUserImportLib.dll", "E:SafeComG3", 1) ; Start the services to complete the process and start working RunWait($Start) ;, @SW_HIDE) ; Finish! Problem Solved! Thanks.
  12. Hello Everyone, I'm creating a script to install a program and i need to apply some patches after the installation is complete. However, those patches require to stop and start some services and i'm unable to do so. The part of the script to manage the services is as follows: ; Patches Start! ; Stop services to be able to copy the patch files RunWait("net stop SafeCom" & "Service", @SW_HIDE) RunWait("net stop Spooler", @SW_HIDE) ; Copy the SafeCom patches to the main directory FileCopy($d & "\scDevUtilLib.dll", "E:\SafeComG3\", 1) FileCopy($d & "\scMoneyServer.exe", "E:\SafeComG3\", 1) FileCopy($d & "\scUserImportLib.dll", "E:\SafeComG3\", 1) ; Start the services to complete the process and start working RunWait("net start Spooler", @SW_HIDE) RunWait("net start SafeCom" & "Service", @SW_HIDE) ; Finish! I know the files are trying to copy themselves, but the services are not stopping preventing the files from being overwritten. Any ideas of what i'm doing wrong? Thanks a lot. Best regards,
  13. Ok, i made it... but it doesn't make any sense... It worked with this: ControlClick($Title, "", "TNewCheckListBox1", "secondary") ControlSend($Title, "", "TNewCheckListBox1", "{SPACE}") Sleep(1000) ControlClick($Title, "", "TNewCheckListBox1", "secondary") ControlSend($Title, "", "TNewCheckListBox1", "{SPACE}") Why would i have to send the command twice to make it work? The first two lines make no effect, and when they are launched for the second time it works and marks the correct option... i don't understand it... ¿?¿? EDIT1: Ok, it works because of the SPACE inputs... ControlClick($Title, "", "TNewCheckListBox1", "secondary") ControlSend($Title, "", "TNewCheckListBox1", "{SPACE}") ControlSend($Title, "", "TNewCheckListBox1", "{SPACE}") This also works, so i guess this is the correct way to do it, at least the best i found so far.
  14. Thanks BrewManNH, I know i can't use the send command, because it is interrupted by screensavers, pop-ups, etc. loosing the focus. But maybe it can work somehow with ControlSend... Here is the thing: http://img.photobucket.com/albums/v358/Daryon/Imagenes/ServerInstallation_001.jpg In some steps of the installation i might find the following, the focus is in the "Next" button, and using TAB i can only navigate through the lower buttons, but it never reaches the 3 items in the check list. Also, those items do not have a send option like an ALT+KEY, sometimes in the installation you can see buttons like "Next >" with a small line indicating the key to press, but in this case that's not possible either. Any ideas or suggestions? Thanks!!! EDIT1: I think i'm close to it guys!!! i used this: ; Select Server Installation Global $Title = "Setup - SafeCom G3" ; Click I Accept the agreement ControlClick($Title, "", "TNewCheckListBox1", "primary") ; Finish! And although the selection marked the wrong item, if i can now send a SPACE or something like that, then i could navigate the menu with TAB. I'll keep trying. EDIT2: Argh!!! It almost worked... http://img.photobucket.com/albums/v358/Daryon/Imagenes/Tools_001.jpg I managed to select the Tools Option, but i need the server option, and i can't move it sending a TAB command, because TAB works only in the lower buttons. ControlClick($Title, "", "TNewCheckListBox1", "primary") ControlSend($Title, "", "TNewCheckListBox1", "{SPACE}") ControlSend($Title, "", "TNewCheckListBox1", "{TAB}")
×
×
  • Create New...