Jump to content
Sign in to follow this  
AntonioGNAL

Impossible to run a reg export

Recommended Posts

AntonioGNAL

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:

Execution_001_zps76e6049b.png

Thanks!

Edited by AntonioGNAL

Share this post


Link to post
Share on other sites
Paramjeet

;modified little bit... try this

 

 
;This is the reg key

#include <File.au3>
 
Global $targetHistory = "HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History"
Global $logHandler
Global $regBackup
 
 
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
Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

Paramjeet,

Welcome to the AutoIt forum. :)

When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______Open Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Paramjeet

Sure

Share this post


Link to post
Share on other sites
AntonioGNAL

;modified little bit... try this

 

 
;This is the reg key

#include <File.au3>
 
Global $targetHistory = "HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History"
Global $logHandler
Global $regBackup
 
 
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

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:

Execution_002_zps2027aac6.png

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?

Edited by AntonioGNAL

Share this post


Link to post
Share on other sites
Palestinian

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

 

You forgot to close the brackets.

  • Like 1

Share this post


Link to post
Share on other sites
AntonioGNAL
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

You forgot to close the brackets.

Oh my God!!! Thanks, i was so obsessed about the conditions i didn't even think about that.

Share this post


Link to post
Share on other sites
sahsanu

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.

 

To try to solve this issue with accents in the RegKey name, change this on your script:

RunWait(@ComSpec & " /c " & $THRegBkup)

to

RunWait(@ComSpec & " /c chcp 1250 && " & $THRegBkup)

And try again.

Un saludo,

sahsanu

 

Share this post


Link to post
Share on other sites
meows

woops I misunderstood what you were doing,,

'?do=embed' frameborder='0' data-embedContent>>

is the way I found

I do not know if this fits your issue but being it is a registry matter, I after 3 months of massive reading and testing find a answer to adding a VAR to the registry..

I stripped what I had to and there isn't any checking for keystroke issues with the input box.. user can input ANYTHING  so if you use it add security to the input box

COPY and paste,, it runs as advertised.. It will add 2 different VAR to the registry and a text file to the desktop

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=cps250.ico
#AutoIt3Wrapper_Outfile=EvalYES.exe
#AutoIt3Wrapper_Res_Comment= equal to
#AutoIt3Wrapper_Res_Description=overlord
#AutoIt3Wrapper_Res_Fileversion=12.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=reardon studio
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; *** Start added by AutoIt3Wrapper ***
#include <FontConstants.au3>
; *** End added by AutoIt3Wrapper ***

;SciTE
;Version 3.3.7
;    Dec 12 2013 20:45:19

#include  "ExtMsgBox.au3"

#include <MsgBoxConstants.au3>
#include <FileConstants.au3>
#include<string.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <Misc.au3>
#include <ColorConstants.au3>
#include <GuiButton.au3>
#include <ExtMsgBox.au3>
#include <constants.au3>
#include <WinAPI.au3>
$Regit1 = GUICreate("reg1", 621, 442, 192, 114)
;Opt("GUIOnEventMode", 1)
Local Const $1Font = "Tahoma"
$hButton1 = GUICtrlCreateButton("Register ", 20, 20, 1, 1, GUISetState(@SW_HIDE))
$hButton6 = GUICtrlCreateButton("Read Me", 20, 20, 1, 1, GUISetState(@SW_HIDE))
$hButton7 = GUICtrlCreateButton("Exit", 20, 20, 1, 1, GUISetState(@SW_HIDE))
GUICtrlSetState($hButton1, @SW_HIDE)
GUISetState(@SW_SHOW, $Regit1)
Button1Click()
Button6Click()
Button7Click()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $hButton1
            Button1Click()


        Case $hButton6
            Button6Click()


        Case $hButton7
            Exit
            Button7Click()


    EndSwitch
WEnd
Func Button6Click()
    Local $securityCodeEncryptionKey = "SonoM1EXHardBonus" ;this must match the applications key
    $str = InputBox("EXHard Registration", "Register to try for SonoM1 Full version Download for Free  Input first and last name")
    If @error = 1 Then Exit

    $Generate = StringUpper(StringRight($str, 5))
    $restore = StringUpper(_StringEncrypt(1, $Generate, $securityCodeEncryptionKey, 1))

    ClipPut($restore)

    MsgBox(0, "EXHard", "The registration code is: " & $restore & "Your code has been placed on the DESKTOP BONUS.TXT and clipboard You can paste it into a text file to save it")
    Local $sEvalString1 = Eval("$restore")
    #forceref $restore
    IniWrite(@DesktopCommonDir & "\BONUS.TXT", "General", "registration", $restore)
    Local $sString = DriveGetSerial(@HomeDrive & "\") ; Find the serial number of the home drive, generally this is the C:\ drive.
    #forceref $sString
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications", "CoreMaker", "REG_MULTI_SZ", "SOFTWARE\Coremaker\SonoM1\BonusAttempt\ControlCenter\Capabilities\" & $sString)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications", "CoreVersion", "REG_MULTI_SZ", "SOFTWARE\Coremaker\SonoM1\" & $restore)
    FileCopy(@DesktopCommonDir & "BONUS.TXT", @AppDataCommonDir & "\BONUS.TXT", $FC_OVERWRITE + $FC_CREATEPATH)
EndFunc   ;==>Button6Click
Func Button1Click()
    GUICtrlSetState($hButton1, $GUI_ENABLE)
    $answer = MsgBox(4, "Get SonoM1 Full Verson for Free", "Get EXHard. ")
    If $answer = 7 Then
        MsgBox(0, "", "OK.  Bye!")
        Exit
    EndIf
    EndFunc   ;==>Button1Click
Func Button7Click()
    Exit
EndFunc   ;==>Button7Click
Edited by meows

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • vyperhand
      By vyperhand
      I'm struggling to launch a VBS file via autoit using RunWait.  Due to the nature of the deployment tool I am using for said script, I only know that the .vbs files will be in the same directory as my AutoIt-generated .exe, but not what that path will be.  The path will look something like this:
      c:\programdata\vendor\lots\of\folders\randomnumber
      This is generated during deployment and I have no way of predicting the path - therefore, I am not sure how to call back to "same directory" in order to successfully launch the .vbs.
      This line is as close as I have gotten - this fires off the cmd window, but it closes immediately with out information, and the .vbs is not launched.
      RunWait (@ComSpec & " /c" & 'cscript.exe WORKPLEASE.vbs ALL /Q /NoCancel') I thought /c might be the problem, but leaving out the /c element causes me not to even see the momentary CMD window flash by.  Any help will be greatly appreciated, and thanks in advance.
    • lewisg
      By lewisg
      Suddenly a RunWait command has stop working after 2 years of no errors, issues, or problems. The code uses RunWait to start Plink.exe, a command-line remote connection tool similar to UNIX ssh. I'm using it to ssh to a linux (Centos) machine, run a Perl script, and redirect the output to a file on a PC running the AutoIt script.  
       
      $FilePath = "C:\AutoIT\LED" $FilePathPlus = $FilePath & "\plink.exe" $Code1 = RunWait(@ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt ", @SW_SHOW) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " = ' & @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console The ConsoleWrite output when cut-n-pasted into a DOS box produces the expected file so I know it works. I've also tried many variations of the function moving, adding, and changing the " and ' (quote) marks. Also tried it without the @ComSpec macro and other related functions...e.g.  ShellExecuteWait , etc.
      The PC is a Windows 10 64bit and AutoIT is version 3.3.14.2.
      Searching here and Google has not yielded any clues that helped. 
    • goodmanjl531
      By goodmanjl531
      Hope someone can help as quotes within quotes is always confusing.  I am creating a silent install of printer software and want to call via runwait comspec line.
      The call within a cmd line is below
      samsung.exe /s /n"Samsung SL-M3220ND" /p"xxx"
      xxx will be stored as a variable  $PrinterIP which would be as example  10.10.10.20    I need to use a variable as i am doign this for a business and need it to be based on the store i install at that has a specific IP range.
       
      I started with the below as 2 possibilities but no luck..
      RunWait(@ComSpec & "/c " & "samsung.exe /s /n""Samsung SL-M3220ND"" /p""" & $PrinterIP ") RunWait(@ComSpec & "/c " & "samsung.exe /s /n'Samsung SL-M3220ND' /p'" & $PrinterIP '") but i cant get it to compile as i have errors on the line..  thanks in advance.
    • tremolux66
      By tremolux66
      Initial Problem
      I've written several scripts with the following sequence:
      Execute a program using Run w/stdout+stderr captured Typically processes all the files in one directory tree to populate a second tree Execute a second program (also with Run) to monitor the products of the first program and Display a progress bar (percentage of output files complete) Also monitor the first program's process and exit when it terminates The script then calls ProcessWaitClose (no timeout) on the first program's process and Checks the first program's results Kills the monitor program if it hasn't already exited on its own. Sometimes, ProcessWaitClose returns 1 with @error = 0 and @extended = 0xCCCCCCCC (actually, 0xFFFFFFFFCCCCCCCC), which seems ambiguous: the documentation says that @error = non-zero and @extended = 0xCC... means an invalid PID (unclear what the return value is), and 1 is returned for non-existent processes (but no mention of @extended). The 1/0/0xCC... result seems to occur when the first program exits very quickly (with or without an error). Since the exit value is not available, the script scans the program's output and tries to determine whether it ran successfully. This has gotten complicated and unreliable.
      Partial Fix
      I've now implemented a much simpler approach that works for most cases:
      Modify the monitor program so that it ignores the other program's process (the monitor always gets killed by the script anyway) Execute the monitor program first using Run, then execute the processing program with RunWait When RunWait returns, the child process exit value is available, so the script can ignore its output (which isn't available anyway) If the monitor program is still running, kill it. Remaining Issue
      However, there are still a couple of cases where it's necessary to get both the exit value from the processing program and its output. Since RunWait doesn't capture stdout and stderr for the parent script, it's looking like I'll have to call RunWait and redirect the 2 streams to a temp file and then scan it. Also, to do the redirect, I think I'll have to use @ComSpec to execute the processing program, which adds an undesired layer.
      Does anybody have a better (cleaner) way to handle these cases?
    • breakbadsp
      By breakbadsp
      I want to run a python script from autoit. 
      I know we can do this with shellexecute or run , but this python script takes 3 cmd line arguments.
      How to pass them from autoit script?
      I tried many ways.
      Following solution also not working 
      e.g. 
      RunWait( 'fullpath\Python.exe Scriptpath\ReadLog.py  -f "file.log" -k "key" -e "errMsg" ') Found solution:
      RunWait( 'fullpath\Python.exe ReadLog.py -f "file.log" -k "key" -e "errMsg" ', 'Working_directory_path')  
      PFB description:
      https://stackoverflow.com/questions/45757834/how-to-pass-command-line-arguments-to-a-python-script-anyscript-while-executin
       
×