Sign in to follow this  
Followers 0
Intel91

Help With the Run Function

6 posts in this topic

#1 ·  Posted (edited)

I wrote an application that consists of multiple segments, I wrote it like that for stability. One folder contains these segments of .exes, and the parent directory contains a script to run or runwait each of these segment one at a time. The problem is, I keep on getting 0 error code returns and can't figure it out, here is what I'm trying to do:

RunWait ("testseg1.exe" , @ScriptDir & "\testlib\")
RunWait ("testseg2.exe" , @ScriptDir & "\testlib\")
RunWait ("testseg3.exe" , @ScriptDir & "\testlib\")

I've tried Run and RunWait both fail. I have also tried directly inserting the full path to the file instead of just @ScriptDir & "\momentumlibs\" but that fails as well, Not just that it returns a 0, I can physically see it isn't creating the directories and performing the functions it was written to do, and that it indeed does when I click on each segment one at a time. I am running Windows 7, and have already tried executing as admin, and tried requiring admin.

EDIT: I think it is worth mentioning when I put my code that is above in the same directory as my segments, then change @ScriptDir & "\testlib\" to just @ScriptDir, everything works.

Thanks,

Intel

Edited by Intel91

Share this post


Link to post
Share on other sites



That did the trick, thank you. However, I think the help file should be looked at, because the example it gives for the run function strongly suggests to setup the code the way I did. It appears to me that the way I did it works only for a macro like @ScriptDir, however not Macro & Dir like most other functions work. This seems to be the only anomaly I have ever seen.

Thanks again,

Intel

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It should work the way Jos mentioned

RunWait (@ScriptDir & "\testlib\testseg1.exe" , @ScriptDir & "\testlib\")
RunWait (@ScriptDir & "\testlib\testseg2.exe" , @ScriptDir & "\testlib\")
RunWait (@ScriptDir & "\testlib\testseg3.exe" , @ScriptDir & "\testlib\")

Or by adding the line FileChangeDir(@ScriptDir & "\testlib\") to your primary script

FileChangeDir(@ScriptDir & "\testlib\")
RunWait ("testseg1.exe")
RunWait ("testseg2.exe")
RunWait ("testseg3.exe")

EDIT:

It should also work with

EnvSet("Path", @ScriptDir & "\testlib\")
RunWait ("testseg1.exe")
RunWait ("testseg2.exe")
RunWait ("testseg3.exe")
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

That did the trick, thank you. However, I think the help file should be looked at, because the example it gives for the run function strongly suggests to setup the code the way I did. It appears to me that the way I did it works only for a macro like @ScriptDir, however not Macro & Dir like most other functions work. This seems to be the only anomaly I have ever seen.

Thanks again,

Intel

It doesn't really. Only when you assume that the Working directory is the path where the program resides, which is not the same.

This is in the current Beta Helpfile:

Parameters

program The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks). 
workingdir [optional] The working directory. This is not the path to the program.
Edited by Jos

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

There is always a lot of confusion about the working directory becuase people don't understand what it is.

http://en.wikipedia.org/wiki/Working_directory

http://www.webopedia.com/TERM/w/working_directory.html

Also create a new script with a single line of code and run it

MsgBox(0, "Result", "Your current working dir is " & @WorkingDir)

The result is seldom what you expect it to be.

So in conclusion, there is nothing wrong with the help file.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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