Jump to content
Sign in to follow this  
miketh2005

How to properly use the Run function? Helpfile doesn't clarify.

Recommended Posts

miketh2005

Hello, I'm trying to use the Run function, but the helpfile doesn't clarify how to use the "workingdir" parameter.

I'm trying to do:

Run("Soldat.exe", "C:/Soldat")

But it doesn't work, even though I have Soldat.exe in the directory "C:/Soldat".

Share this post


Link to post
Share on other sites
Hawkwing

Why not just do

Run("C:\Soldat\Soldat.exe")

Or, as it is in the other post on this exact same topic

Run($var & "Soldat.exe")
Edited by Hawkwing

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites
somdcomputerguy

Try

Run("Soldat/Soldat.exe", "C:/Soldat")

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
miketh2005

Why not just do

Run("C:\Soldat\Soldat.exe")

That works! Thanks! Why didn't they say that in the helpfile? :/

Share this post


Link to post
Share on other sites
Richard Robertson

It does. The first parameter is the path to the executable. That's as explicit as it gets.

Share this post


Link to post
Share on other sites
miketh2005

It does. The first parameter is the path to the executable. That's as explicit as it gets.

It would be good is that's what it actually said in the helpfile, but it does not. It says:

Parameter Description

filename The name of the executable (EXE, BAT, COM, or PIF) to run.

workingdir [optional] The working directory.

It says the filename, not the path to the filename.

Share this post


Link to post
Share on other sites
BrettF
Richard Robertson

I have submitted a ticket to the trac requesting a documentation change. #1139

Share this post


Link to post
Share on other sites
miketh2005

Search would have received even more results...

I'm sorry. I always forget that ;/ thanks for reminding me. Thanks richard for submitting that ticket.

Share this post


Link to post
Share on other sites
trancexx

I'm just reading v3.3.1.1 (beta) help file and this is fixed there.

Ticket is redundant.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
JSThePatriot

Hello, I'm trying to use the Run function, but the helpfile doesn't clarify how to use the "workingdir" parameter.

I'm trying to do:

Run("Soldat.exe", "C:/Soldat")

But it doesn't work, even though I have Soldat.exe in the directory "C:/Soldat".

Just so you know you had this exactly right, except the problem you are experiencing is the wrong direction for a directory slash \ = operating system directory where as / = web application directory.

Try the following (even though you have working code)

Run("Soldat.exe", "C:\Soldat")

Let me know if that works for you.

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites
miketh2005

Just so you know you had this exactly right, except the problem you are experiencing is the wrong direction for a directory slash \ = operating system directory where as / = web application directory.

Try the following (even though you have working code)

Run("Soldat.exe", "C:\Soldat")

Let me know if that works for you.

Jarvis

Nope, doesn't work.

Share this post


Link to post
Share on other sites
BrettF
JSThePatriot

Nope, doesn't work.

It works for me...read below for details.

It would only work if the .exe was in the script folder...

Incorrect. That's what the working directory is for (changes run location).

Edit01: BrettF your statement would only be true with the following code as that would imply the run directory is the working directory.

Run("Soldat.exe")

Please perform the following steps to confirm what I have done.

  • Create Folder "Soldat" on the C:\ Drive
  • Create a script as follows...(Soldat.au3)

    MsgBox(0, "Test", "Success!")
  • Compile that script as Soldat.exe
  • Place that script in C:\Soldat\ directory
  • Write another script in C:\Documents and Settings\Username\My Documents\Personal\AutoIt\SoldatTest.au3

    Run("Soldat.exe", "C:\Soldat")
  • Compile that script as SoldatTest.exe
  • Run it from the AutoIt folder.

Result: Message box showing "Success!" is popped up. My working directory is as stated above.

If anyone can produce different results let me know.

Thanks,

Jarvis

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites
Richard Robertson

I'm just reading v3.3.1.1 (beta) help file and this is fixed there.

Ticket is redundant.

Whoops. I checked the online copy of the help documents, so I didn't know about that.

It works for me...read below for details.

Incorrect. That's what the working directory is for (changes run location).

Edit01: BrettF your statement would only be true with the following code as that would imply the run directory is the working directory.

Run("Soldat.exe")

Please perform the following steps to confirm what I have done.

  • Create Folder "Soldat" on the C:\ Drive
  • Create a script as follows...(Soldat.au3)

    MsgBox(0, "Test", "Success!")
  • Compile that script as Soldat.exe
  • Place that script in C:\Soldat\ directory
  • Write another script in C:\Documents and Settings\Username\My Documents\Personal\AutoIt\SoldatTest.au3

    Run("Soldat.exe", "C:\Soldat")
  • Compile that script as SoldatTest.exe
  • Run it from the AutoIt folder.

Result: Message box showing "Success!" is popped up. My working directory is as stated above.

If anyone can produce different results let me know.

Thanks,

Jarvis

I'm surprised that works. The working directory has nothing to do with the list of directories used to find an executable.

Share this post


Link to post
Share on other sites
BrettF
Richard Robertson

My guess is that AutoIt will now set the working directory and then run the application, in that order.

Share this post


Link to post
Share on other sites
Scriptonize

I've always thought that the working folder doesn't need to be the same as the exe folder. >_<

The exe can be in c:\program files\myprog\myprog.exe

Myprog.exe can have a file open in c:\test.

Isn't (in my example) the working folder c:\test ?


If you learn from It, it's not a mistake

Share this post


Link to post
Share on other sites
Richard Robertson

Yes that's partially true. The working directory and the executing directory do not have to be the same.

Share this post


Link to post
Share on other sites
JSThePatriot

Well I am happy I could surprise! >_<

I know that Soldat.exe isn't in the %PATH% environment variable, and because it's outside my running directory, I had to specify the working directory so AutoIt would know where to find it.

Regards,

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.