Jump to content

run function working directory


Surgery
 Share

Recommended Posts

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?

Link to comment
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?

Link to comment
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.
Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...