Jump to content
Sign in to follow this  
bhombs

Run won't work

Recommended Posts

bhombs

Hello,

I can't figure out why this command won't work:

run("C:\Documents and Settings\user.name\My Documents\putty.exe")

It has worked for years, now all of a sudden when I use this command I get an error saying "Unable to execute external command"

However, this command will work:

run("C:\putty.exe")

I know the file is in both places. The paths are correct (I even used FileExists to double check).

Please help.

Share this post


Link to post
Share on other sites
Monamo

Hello,

I can't figure out why this command won't work:

run("C:\Documents and Settings\user.name\My Documents\putty.exe")

It has worked for years, now all of a sudden when I use this command I get an error saying "Unable to execute external command"

However, this command will work:

run("C:\putty.exe")

I know the file is in both places. The paths are correct (I even used FileExists to double check).

Please help.

Try specifying the working directory and see if that helps:

Run("C:\Documents and Settings\user.name\My Documents\putty.exe", "C:\Documents and Settings\user.name\My Documents\")

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites
GEOSoft

Run(@DocumentsDir & "\putty.exe")

or

Run(FileGetShortName("C:\Documents and Settings\user.name\My Documents") & "\putty.exe")

or

Run('"C:\Documents and Settings\user.name\My Documents\putty.exe"')


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
bhombs

Thanks you. So this worked:

Run(FileGetShortName("C:\Documents and Settings\user.name\My Documents") & "\putty.exe")

Here is the question. What could have caused this to change? I have many scripts that have run for a long time without the FileGetShortName command and now I have to go through them all and change them.

Is there a parameter in the operating system or something?

Share this post


Link to post
Share on other sites
Richard Robertson

It might be the spaces in the filename.

Edited by Richard Robertson

Share this post


Link to post
Share on other sites
GEOSoft

Thanks you. So this worked:

Run(FileGetShortName("C:\Documents and Settings\user.name\My Documents") & "\putty.exe")

Here is the question. What could have caused this to change? I have many scripts that have run for a long time without the FileGetShortName command and now I have to go through them all and change them.

Is there a parameter in the operating system or something?

As Richard Robertson pointed out, if there are spaces in the path then you will have a problem. You must use FileGetShortName() ( prefered ) or enclose the path in double quotes. In order to do that then you also have to enclose the entire path in single quotes ( or double up your double quotes, which is not so good ).

If that line worked then any of the others should also have worked providing you were working with your own "My Documents" folder. If not, then either the second or third should work. Notice that in the third I enclosed the double quotes inside of single quotes.


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
bhombs

As Richard Robertson pointed out, if there are spaces in the path then you will have a problem. You must use FileGetShortName() ( prefered ) or enclose the path in double quotes. In order to do that then you also have to enclose the entire path in single quotes ( or double up your double quotes, which is not so good ).

If that line worked then any of the others should also have worked providing you were working with your own "My Documents" folder. If not, then either the second or third should work. Notice that in the third I enclosed the double quotes inside of single quotes.

Thanks again for your help.

I know what you're saying and that makes sense. The thing is, 2 days ago I never had to do this in scripts. In addition, another link with spaces works just fine right now:

run("C:\Program Files\Microsoft Office\Office10\OUTLOOK.EXE")

Is there something about certain exes that would cause this?

Really odd.

Share this post


Link to post
Share on other sites
TheCuz

Did you always use a string literal for the path of the file that you wanted to run, or did you use a combination of a macro and a string?

Just curious....


[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Share this post


Link to post
Share on other sites
MHz

Is there something about certain exes that would cause this?

Change of directory structure or a system setting perhaps. You have been lucky so far as to using unquoted paths with spaces and should consider adding quotes to protect paths executed by that may have spaces as default.

:)

Share this post


Link to post
Share on other sites
bhombs

Did you always use a string literal for the path of the file that you wanted to run, or did you use a combination of a macro and a string?

Just curious....

I've done both. Both stopped working.

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  

×