Jump to content

@ComSpec Command-line arguments ERROR


Go to solution Solved by argumentum,

Recommended Posts

Running it directly without going through cmd.exe is no problem.

Local $sCommand = '"' & @ScriptDir & '\SumatraPDF-3.2-64.exe' & '"' &' -print-to "RICOH SP 210 NET" -print-settings "fit,paper=A4" -silent -exit-when-done "D:\_Work_\AutoPrint\BG_00.pdf"'
Run($sCommand, '', @SW_HIDE)


But I need to get error information !

I don't know where I am wrong, can you help me see where the problem lies?

Error: 'D:\_Work_\AutoPrint\SumatraPDF-3.2-64.exe" -print-to "RICOH' is not recognized as an internal or external command,
operable program or batch file.

Script:

#include <File.au3>
If @OSArch = "X64" And Not @AutoItX64 Then _Wow64FsRedirection(0)

Local $sCommand = '"' & @ScriptDir & '\SumatraPDF-3.2-64.exe' & '"' &' -print-to "RICOH SP 210 NET" -print-settings "fit,paper=A4" -silent -exit-when-done "D:\_Work_\AutoPrint\BG_00.pdf"'
_StreamCMD($sCommand)
;_RunCmd_GetOutput($sCommand)

Func _RunCmd_GetOutput($sCommand)
    ConsoleWrite("> Execute: " & $sCommand & @CRLF)
    ConsoleWrite("! Full CMD: " & '"' & @ComSpec & '" /c ' & $sCommand & @CRLF)
    Local $sOutput = '', $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, '', @SW_HIDE, 0x6)
    Do
        $sOutput &= StdoutRead($iPID)
    Until @error
    Do
        $sOutput &= StderrRead($iPID)
    Until @error
    ConsoleWrite($sOutput & @CRLF)
    Return $sOutput
EndFunc   ;==>_RunCmd_GetOutput


Func _StreamCMD($sCMD, $sCallBackFunction = Default, $WorkingDir = Default, $iStreamType = Default, $iShowFlag = Default, $iDelay = Default)
    If StringStripWS($sCMD, 8) = "" Then Return ""
    If $sCallBackFunction = Default Then $sCallBackFunction = "ConsoleWrite"
;~  If $WorkingDir = Default Then $WorkingDir = @SystemDir ;@WindowsDir & '\System32'
    If $WorkingDir = Default Then $WorkingDir = @WindowsDir & '\System32'
    If $iStreamType = Default Then $iStreamType = $STDERR_CHILD + $STDOUT_CHILD
    If $iShowFlag = Default Then $iShowFlag = False
    If $iDelay = Default Then $iDelay = 250
    ConsoleWrite("> Execute: " & $sCMD & @CRLF)

    Local $sTMP = '', $sSTD = '', $sCOM = '"' & @WindowsDir & '\System32\cmd.exe"' & ' /c ' & $sCMD
;~  Local $sTMP = '', $sSTD = '', $sCOM = @ComSpec & ' /c ' & $sCMD
    ConsoleWrite("! Full CMD: " & $sCOM & @CRLF)
    Local $iWin = $iShowFlag ? @SW_SHOW : @SW_HIDE
    Local $iPID = Run($sCOM, $WorkingDir, $iWin, $iStreamType)
    While 1
        $sTMP = StdoutRead($iPID, False, False)
        If @error Then ExitLoop
        If $sTMP <> "" Then
            $sTMP = StringReplace($sTMP, @CR & @CR, '')
            $sSTD &= $sTMP
            Call($sCallBackFunction,$sTMP)
;~          ConsoleWrite($sTMP)
            Sleep($iDelay)
        EndIf
    WEnd
    While 1
        $sTMP = StderrRead($iPID, False, False)
        If @error Then ExitLoop
        If $sTMP <> "" Then
            $sTMP = StringReplace($sTMP, @CR & @CR, '')
            $sSTD &= $sTMP
            Call($sCallBackFunction,$sTMP)
;~          ConsoleWrite($sTMP)
            Sleep($iDelay)
        EndIf
    WEnd
;~  If $sSTD <> "" Then ConsoleWrite(@CRLF)
    Return SetError(@error, @extended, $sSTD)
EndFunc   ;==>_StreamCMD
; * -----:|  Dao Van Trong - TRONG.WIN

Func _Wow64FsRedirection($state)
    If @OSArch = "X64" Then
        If $state Then
            ;DllCall("kernel32.dll", "int", "Wow64EnableWow64FsRedirection", "int", 1)
            DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "int", 0)
        Else
            ;DllCall('kernel32.dll', 'boolean', 'Wow64EnableWow64FsRedirection', 'boolean', False)
            DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0)
        EndIf
        If @error Then Return SetError(1, 0, 0)
        Return 1
    EndIf
EndFunc   ;==>_Wow64FsRedirection

Log:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "D:\_Work_\AutoPrint\_AutoPrint.au3" /UserParams    
+>09:26:48 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000409  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTe   UserDir => C:\Users\Trong\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Trong\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.15.4)  from:C:\Program Files (x86)\AutoIt3  input:D:\_Work_\AutoPrint\_AutoPrint.au3
+>09:26:48 AU3Check ended.rc:0
>Running:(3.3.15.4):C:\Program Files (x86)\AutoIt3\autoit3.exe "D:\_Work_\AutoPrint\_AutoPrint.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
> Execute: "D:\_Work_\AutoPrint\SumatraPDF-3.2-64.exe" -print-to "RICOH SP 210 NET" -print-settings "fit,paper=A4" -silent -exit-when-done "D:\_Work_\AutoPrint\BG_00.pdf"
! Full CMD: "C:\WINDOWS\System32\cmd.exe" /c "D:\_Work_\AutoPrint\SumatraPDF-3.2-64.exe" -print-to "RICOH SP 210 NET" -print-settings "fit,paper=A4" -silent -exit-when-done "D:\_Work_\AutoPrint\BG_00.pdf"
'D:\_Work_\AutoPrint\SumatraPDF-3.2-64.exe" -print-to "RICOH' is not recognized as an internal or external command,
operable program or batch file.
+>09:26:49 AutoIt3.exe ended.rc:0
+>09:26:49 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.71

 

image.thumb.png.65d7d46a6eaaf68f43bfcd52ab2d2e9e.png

Thanks

Edited by VIP

Regards,
 

Link to comment
Share on other sites

try Local $sCommand = '"" "' & @ScriptDir & '\SumatraPDF-3.2-64.exe' & '"'

Those extra " may do the trick with cmd.exe. Let me know.

Edit: also https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1478119 may be useful.

 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Thanks for the help guys.
But I don't really understand why is that?
It must be a cmd  or AutoIT bug?

The script worked:

Local $sCommand = '""' & @ScriptDir & '\SumatraPDF-3.2-64.exe' & '"' &' -print-to "RICOH SP 210 NET" -print-settings "fit,paper=A4" -silent -exit-when-done "D:\_Work_\AutoPrint\BG_00.pdf"'
> Execute:
""D:\_Work_\AutoPrint\SumatraPDF-3.2-64.exe" -print-to "RICOH SP 210 NET" -print-settings "fit,paper=A4" -silent -exit-when-done "D:\_Work_\AutoPrint\BG_00.pdf"

! Full CMD: 
"C:\WINDOWS\System32\cmd.exe" /c ""D:\_Work_\AutoPrint\SumatraPDF-3.2-64.exe" -print-to "RICOH SP 210 NET" -print-settings "fit,paper=A4" -silent -exit-when-done "D:\_Work_\AutoPrint\BG_00.pdf"

 

Regards,
 

Link to comment
Share on other sites

  • Solution

Run(@ComSpec & ' /c "title this is the new title"&&dir&&pause')
Is not an AutoIt bug. Is a cmd.exe (buggy)feature to add a title. =/
I've had these problems before and that's how I know of the solution.
That I did not know was about the ^ use.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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