Sign in to follow this  
Followers 0
Gene

Having trouble with RunWait command

11 posts in this topic

#1 ·  Posted (edited)

The following code...

$sBasePath = FileSelectFolder ( "Select folder to process", "My Computer" , 2 )

MsgBox(0, "Command line", @ComSpec & " /c " &  "dir " & $sBasePath & "\*.jpg /o:d /b " & "  > " & $sBasePath & "\" & $sFile2Process)

RunWait(@ComSpec & " /c " &  "dir " & $sBasePath & "\*.jpg /o:d /b " & "  > " & $sBasePath & "\" & $sFile2Process, 5 )

produces the following result...

The MsgBox gives:

C:\WINNT\system32\cmd.exe /c dir K:\_JPG\050202\*.jpg /o:d /b > K:\_JPG\050202\DirList.TXT

the RunWait command gives this error message:

Line 9 (File "C:\RenameAsNeeded.Au3"):

RunWait(@ComSpec & " /c " & "dir " & $sBasePath & "\*.jpg /o:d /b " & " > " & $sBasePath & "\" & $sFile2Process, 5 )

Error: Unable to execute the external program.

The directory name is invalid.

When I run the command shown by the MsgBox at a command prompt it produces a date ordered list of files in the specified text file. Can anyone say why the RunWait command doesn't get the same result?

Edited by Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites



change @comspec /c

to

@comspec /k

for debugging

Share this post


Link to post
Share on other sites

change @comspec /c

to

@comspec /k

for debugging

<{POST_SNAPBACK}>

OK, I did that. No change from before except the MsgBox and error dialog displayed the "k" instead of the "c". The command prompt window remained open with the command shown by the MsgBox displayed, when executed it produced the expected file. The script still failed at the RunWait command. I do appreciate the response.

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

OK, I did that.  No change from before except the MsgBox and error dialog displayed the "k" instead of the "c".  The command prompt window remained open with the command shown by the MsgBox displayed, when executed it produced the expected file.  The script still failed at the RunWait command.  I do appreciate the response.

<{POST_SNAPBACK}>

are you testing @error

with opt(r"runerrorsfatal",0) ;that is not exact

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i think the problem is ur use of qoutation marks because u r using a variable ...try going off this ...

Run(@ComSpec & ' /c xcopy /e /h /y "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE)

that is a snippet from a script that i made .. it works

Edited by burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

are you testing @error

with opt(r"runerrorsfatal",0) ;that is not exact

<{POST_SNAPBACK}>

No, but if the RunWait command fails there is no reason to the script to continue.

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

i think the problem is ur use of qoutation marks because u r using a variable ...try going off this ...

Run(@ComSpec & ' /c xcopy /e /h /y "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE)

that is a snippet from a script that i made .. it works

<{POST_SNAPBACK}>

If my dbl quotes were unbalanced or needed to be shown on the command line I would probably agree with you. In my initial post I mentioned that the MsgBox showed the command line before it was handed to the RunWait command. What it shows is perfect, and when pasted in at a DOS prompt it runs and produces as expected.

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

Line 9  (File "C:\RenameAsNeeded.Au3"):

RunWait(@ComSpec & " /c " &  "dir " & $sBasePath & "\*.jpg /o:d /b " & "  > " & $sBasePath & "\" & $sFile2Process, 5 )

Error: Unable to execute the external program.

The directory name is invalid.

A simple view of your runwait command.

RunWait( "Your Commands", 5)

What is the ,5 for ?

Share this post


Link to post
Share on other sites

A simple view of your runwait command.

RunWait( "Your Commands", 5)

What is the ,5  for ?

<{POST_SNAPBACK}>

Good question, I don't have a clue, I removed it and here are the results...

$sBasePath = FileSelectFolder ( "Select folder to process", "My Computer" , 2 )
;Run(@ComSpec & " /c " & "cd /d " & $sBasePath, @SW_MINIMIZE )

MsgBox(0, "Command line", @ComSpec & " /c " &  "dir " & $sBasePath & "\*.jpg /o:d /b " & "  > " & $sBasePath & "\" & $sFile2Process)
RunWait(@ComSpec & " /c " &  "dir " & $sBasePath & "\*.jpg /o:d /b " & "  > " & $sBasePath & "\" & $sFile2Process, @SW_MINIMIZE )

MsgBox output below:

C:\WINNT\system32\cmd.exe /c dir K:\_JPG\050202\*.jpg /o:d /b > K:\_JPG\050202\DirList.TXT

Error message below:

Line 10 (File "C:\RenameAsNeeded.Au3"):

RunWait(@ComSpec & " /c " & "dir " & $sBasePath & "\*.jpg /o:d /b " & " > " & $sBasePath & "\" & $sFile2Process, @SW_MINIMIZE )

Error: Unable to execute the external program.

The directory name is invalid.

Thank you for pointing that out. Unfortunately, the result didn't change.


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

RunWait ( "filename" [, "workingdir" [, flag]] )

I still think you missed something. The working directory parameter.

E.g.

RunWait( "Your Commands", "", @SW_MINIMIZE)

instead of

RunWait( "Your Commands", @SW_MINIMIZE)

Share this post


Link to post
Share on other sites

RunWait ( "filename" [, "workingdir" [, flag]] )

I still think you missed something. The working directory parameter.

E.g.

RunWait( "Your Commands", "", @SW_MINIMIZE)

instead of

RunWait( "Your Commands", @SW_MINIMIZE)

<{POST_SNAPBACK}>

Yup, that would be correct. I got so focused on the command line and the flag that I forgot about that little piece in between.

Thanks to all for your help!


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

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  
Followers 0