Sign in to follow this  
Followers 0
VeeDub

Unable to execute the external program

4 posts in this topic

Hi,

I am working on an AutoIt v3 script, which I have working under XP, but am encountering problems when I try and run on W2K.

The problem I am having occurs when I call an external program rsync.exe

I build a command string with a whole bunch of arguments depending on various options, and then I use Run to spawn the process

$Command = @comspec & " /c rsync.exe "  & (then a whole bunch of arguments) & "1>path\program_output.txt" & " " & "2>path\error_output.txt"
Run($Command, "",@SW_HIDE)

When I include the redirect statements (in W2K), the script falls over with "unable to execute the external program". If I remove the redirect statements the Run command works.

However if I change the script to open a cmd window:

$Command=@comspec & " /k "
Run($Command,"")

and then I manually paste the full command statement into the cmd window which the script has opened, then the full command including the redirect statements works fine.

That got me thinking that perhaps there might be some "hidden" characters in my $Command string that I couldn't see in the msgbox, so that what I was pasting into the cmd window manually - was somehow different to the actual $Command string being generated by the script.

So I wrote the $Command string to a text file, and then copied & pasted that string into the cmd window created by the script, and that works too B)

Would appreciate any suggestions on how to troubleshoot, ideally I'd like to just 'tweak' my script rather than completely re-write it. But ultimately I need to work out a way to make it work.

Thanks,

VW

Share this post


Link to post
Share on other sites



Hi,

I just figured this out!

I stuck a set of quotes around the outside of the whole command string, and lo and behold it works.

$Command = @comspec & " /c " & """" & "<original command plus arguments including redirect statements>" & """"

Cheers,

VW

Share this post


Link to post
Share on other sites

Hi,

Turns out I jumped to a conclusion. At the same time as I was testing the command-line argument, I commented out some code (which I thought I didn't need) which included a call to RunAsSet.

It turns out that when I change the credentials with RunAsSet, this breaks the command-line argument.

I haven't yet figured out exactly why this happens, but I am certain (this time) B) that it is RunAsSet which is causing the Run command to crash.

VW

Share this post


Link to post
Share on other sites

Do a search on RunAsSet and you will find an answer to this specific question a zillion times... B)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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