Sign in to follow this  
Followers 0
Surgery

run function working directory

7 posts in this topic

Hey,

Ok, so I'm going:

Run("Tonic.exe","in")

because the program is in a folder called "in". But when I run the converted script it says it can't find program. I've also tried:

Run("in\Tonic.exe")

and i get an incorrect number of parameters error at line -1, but the program runs after i close the alert. I imagine I'm just not using the working directory parameter correctly?

Share this post


Link to post
Share on other sites



The full location is needed

Run("C:\In\Tonic.exe")

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

So . . . than that means I can't have relative paths? I would like to have the folder that my script and the folder "in" is in able to be anywhere on the hard drive and still work. But if I use an absolute path I can't do that, right?

Share this post


Link to post
Share on other sites

read help

Run ( "filename" [, "workingdir" [, flag[, standard_i/o_flag]]] )

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

So . . . than that means I can't have relative paths? I would like to have the folder that my script and the folder "in" is in able to be anywhere on the hard drive and still work. But if I use an absolute path I can't do that, right?

The working directory has nothing to do with where the app is called from.
Run ( 'In\Tonic.exe' )
should work if the script is in the directory above In. The working directory is the app's working directory. Think about it. If you used
Run ( @comspec & ' /k', 'In' )
, and you use the standard $P$G prompt, the first line in your command window would be

C:\Above\In>

which is your working directory.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

MsgBox(64, 'File Find', _FileFind("mspaint.exe"))

Func _FileFind($sFName, $hDir = @HomeDrive)
    Local $iPid = Run(@ComSpec & ' /c ' & 'dir "' & $hDir & "\*" & $sFName  _
            & '" /b /o-e /od /s /a-d', '', @SW_HIDE, 2)
    Return StdoutRead($iPid)
EndFunc

Edit:

For clarity:

http://www.autoitscript.com/forum/index.ph...st&p=420170

My response was to the above post.

You could do @ScriptDir as the $hDir parameter if you don't know it's exact path, but know it will be the scripts directory.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

well,

Run ( 'In\Tonic.exe' )

does technically work, but I keep getting an error that says incorrect number of parameters in function call at line -1. Everything is peachy after that, but I would rather do without that little error when I run the program every time.

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