Jump to content

Problem with RegEnumKey/RegDelete/RegWrite


Go to solution Solved by mLipok,

Recommended Posts

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!!!

Edited by AntonioGNAL
Link to comment
Share on other sites

If you want good and quick answer, change you topic tilte.

Look here: Asking the right question right

and here post #3

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Did you read this.

Try

RegEnumKey("HKEY_CURRENT_USER\SYSTEM",1)

Edit:

RegEnumKey("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History", 1 )
Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

 

Did you read this.

Try

RegEnumKey("HKEY_CURRENT_USER\SYSTEM",1)

Edit:

RegEnumKey("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History", 1 )

 

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.

Link to comment
Share on other sites

manualy in regedit

in

"HKEY_CURRENT_USERSoftwareHewlett-PackardHP Print SettingsUbicación predeterminada"

change

"Ubicación predeterminada" >> "test"

now try this:

ConsoleWrite(RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "Target0" )  & @CRLF)
ConsoleWrite('@error = ' & @error & @CRLF)
ConsoleWrite(RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "TargetAge0" ) & @CRLF)
ConsoleWrite('@error = ' & @error & @CRLF)

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

 

manualy in regedit

in

"HKEY_CURRENT_USERSoftwareHewlett-PackardHP Print SettingsUbicación predeterminada"

change

"Ubicación predeterminada" >> "test"

now try this:

ConsoleWrite(RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "Target0" )  & @CRLF)
ConsoleWrite('@error = ' & @error & @CRLF)
ConsoleWrite(RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "TargetAge0" ) & @CRLF)
ConsoleWrite('@error = ' & @error & @CRLF)

 

I'm not getting any output. :-/

I have a batch file with a similar purpose which in essence does this:

@SET filepath=C:RegKey_TH_Bkup

@SET logpath=C:RegKey_TH_Bkup%computername%_PQ_ContingencyLog.txt

@SET regpath="HKEY_CURRENT_USERSoftwareHewlett-PackardHP Print SettingsUbicación predeterminadaTarget History"

echo verifying registry key existance >> %logPath%

reg query %regpath%

if %errorlevel% EQU 0 echo INFORMATION: Key found >> %logPath%

if %errorlevel% NEQ 0 goto abort

echo Exporting registry information to backup the UPD target hisrtory. >> %logpath%

reg export %regpath% %filepath%%computername%_TarHist.reg >> %logpath%

if not exist %filepath%%computername%_TarHist.reg goto abort

echo Windows Registry Editor Version 5.00 > TargetHistory.reg

echo. >> TargetHistory.reg

echo [-HKEY_CURRENT_USERSoftwareHewlett-PackardHP Print SettingsUbicación predeterminadaTarget History] >> TargetHistory.reg

echo. >> TargetHistory.reg

regedit /s TargetHistory.reg

echo Windows Registry Editor Version 5.00 > AddBlankKey.reg

echo. >> AddBlankKey.reg

echo [HKEY_CURRENT_USERSoftwareHewlett-PackardHP Print SettingsUbicación predeterminadaTarget History] >> AddBlankKey.reg

echo. >> AddBlankKey.reg

regedit /s AddBlankKey.reg

 

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.

Edited by AntonioGNAL
Link to comment
Share on other sites

I see my mistake:

try 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 $s12 = RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "TargetAge0")
ConsoleWrite('$s2:' & @CRLF & $s2 & @CRLF & '@error = ' & @error & @CRLF)

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

 

I see my mistake:

try 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 $s12 = RegRead("HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\test\Target History", "TargetAge0")
ConsoleWrite('$s2:' & @CRLF & $s2 & @CRLF & '@error = ' & @error & @CRLF)

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

 

Edited by AntonioGNAL
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Solution

Edit: Sorry, it's just because there's a ")" missing at the end of the first call.

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)

 

sorry

I wrote without checking, and today I have a little confusion.

it is good you change it, but read doc:

 

This does not write to a DOS console unless the script is compiled as a console application.

ConsoleWrite() - usualy is used to write in SciTE console so you must using F5 (GO) not F7 (BUILD)

 

 

My suspicions were confirmed.

RegRead probably not correctly read the data from the key, which in "keyname" or in "valuename" using diacritical marks.

EDIT:

I wrote my post before reading your last (I did not notice as appeared in during my writing)

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

sorry

I wrote without checking, and today I have a little confusion.

it is good you change it, but read doc:

ConsoleWrite() - usualy is used to write in SciTE console so you must using F5 (GO) not F7 (BUILD)

 

 

My suspicions were confirmed.

RegRead probably not correctly read the data from the key, which in "keyname" or in "valuename" using diacritical marks.

EDIT:

I wrote my post before reading your last (I did not notice as appeared in during my writing)

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.

Edited by AntonioGNAL
Link to comment
Share on other sites

use

ShellExecuteWait(@ComSpec , "/k regedit.exe /e " & $regBackup & "TargetHistory.reg " & $targetHistory)

you will be able to see what happen

edit:

(( corected in code

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

use

ShellExecuteWait(@ComSpec , "/k regedit.exe /e " & $regBackup & "TargetHistory.reg " & $targetHistory)

you will be able to see what happen

edit:

(( corected in code

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.

Edited by AntonioGNAL
Link to comment
Share on other sites

do you saw my

 

edit:

(( corected in code

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...