Sign in to follow this  
Followers 0
ledigeine

How to set path for RUN?

8 posts in this topic

I am trying to run an exe that is here we'll say, g:\folder

When trying this, Run(@ComSpec & " /c " & "g:\folder\file.exe" , "", @SW_HIDE) my program will error out.

So if i open a cmdprompt then do the old:

g:

cd\folder

then type file.exe

it will launch.

How with RUN would I recreate that?

Also if i just open a cmdprompt and type, g:\folder\file.exe it will error just the same as that run command up there.

Looks like I need to be in the folder before i can do the exe for my program to actually launch with out errors.

Sorry i have looked around but didnt seem to find anything.

Share this post


Link to post
Share on other sites



What error are you getting? Saying it "error(s) out" is really not helpful to troubleshooting your issue.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Oh i said that because its an error related to the program im calling... its not an autoit error.

The program i work with will error when I call it while not at its path. So if im starting at C: and run g:folderfile.exe it will error. But if i go to g:folder and run file.exe it will run just fine.

With the Run command can you run something from a set path?

I hope this is more clear.

Share this post


Link to post
Share on other sites

You are talking about setting the working directory, which is the second parameter to Run(). I will let you piece that puzzle together.

Thank you... i think with all the other jazz in my run command that i pulled from the helpfile or these forums was a bit confusing. So i didnt know what part I could change while letting it still do its thing.

I guess i need to understand the @comspec part as well as the " /c " part... i didnt think i could alter that so i didnt really wana alter much else.

Working now!

Share this post


Link to post
Share on other sites

@Comspec is just a macro shortcut to the cmd.exe program, usually located in C:\Windows\system32 on x86 systems. The /c tells the cmd.exe program to close the console window after the program has finished running, use /k to keep it open if you need to see what if any output is in the window for debugging purposes. The @SW_HIDE at the end of the statement keeps the console window hidden, so it opens cmd.exe in a window, but you never see it, which is why you NEED to use /c if you're going to keep the window hidden because there's no way to close the cmd.exe window after it has finished other than through the task manager.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thank you sir for explaining this all, was always afraid of that line of code ha.

Share this post


Link to post
Share on other sites

Glad I could help, not everything is in the help file (or easily found if it is in there).


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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