Sign in to follow this  
Followers 0
Snapper

Issues with RUN Function

11 posts in this topic

Hello,

Earlier today I was working on a few AutoIt scripts and was changing a few functions within the scripts to some other functions for testing, when all of a sudden, programs that were written prior to this were unable to open programs I have scripted to run during certain events. For example; any program with the RUN() function will no longer run, but SHELLEXECUTE() will work fine. I experimented with several variations with this, such as running notepad.exe, moving to another directory, and testing with another machine. The other machine has the word-for-word writing and can run perfectly fine. I take the compiled script from my other machine and run it with the same programs installed to the Program Files and it cannot run, saying the file does not exist. I am unable to troubleshoot this issue, and was wondering if there is some sort of global registry or any other potential fix to this issue. Thank you.

Share this post


Link to post
Share on other sites



Interesting development with my issue with RUN() no longer working; using run with any .exes within Program Files does not work, but when I try to launch an .exe from my desktop, it works fine. Any input on this problem?

Share this post


Link to post
Share on other sites

Operating system? Sample code?

Share this post


Link to post
Share on other sites

Are you actually using the full path the program, as is required with the Run function?

Share this post


Link to post
Share on other sites

Sorry about my lack of information: WinXP SP2, and some sample code:

; Checks to see if the file exists
If FileExists( "C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe" ) Then MsgBox(0, "", "True") 
; Launches the executable
Run( "C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe" )

The message box comes up as True, yet, cannot run the executable.

; Checks to see if the file exists
If FileExists( "C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe" ) Then MsgBox(0, "", "True") 
; Launches the executable
ShellExecute( "C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe" )

The message box comes up as True and launches the executable.

; Checks to see if the file exists
If FileExists( "C:\Documents and Settings\MyComputerUserName\Desktop\Firefox Setup 3.5.exe" ) Then MsgBox(0, "", "True") 
; Launches the executable
Run( "C:\Documents and Settings\MyComputerUserNAme\Desktop\Firefox Setup 3.5.exe" )

The message box comes up as True and launches the executable.

It seems like the RUN() command works for executable files in places other than Program Files, but still works for places other than Program Files. Any suggestions into this issue?

Share this post


Link to post
Share on other sites

Have you tried supplying a working directory?

Share this post


Link to post
Share on other sites

I tried the following:

; Checks to see if the file exists
If FileExists( "C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe" ) Then MsgBox(0, "", "True") 
; Launches the executable
Run( "C:\Program Files\SSH Communications Security\SSH Secure Shell", "SshClient.exe" )

This produced a result of the executable running. The strange thing is that all of my old scripts had just a directory straight to the executable (like my first AutoIt script example) and worked fine until recently.

Share this post


Link to post
Share on other sites

Wrapped the run path in speach marks.

Included the full path to the exe and set te working directory as the exe path.

Try that

; Checks to see if the file exists
If FileExists( "C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe" ) Then MsgBox(0, "", "True") 
; Launches the executable
Run( '"C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe"', "C:\Program Files\SSH Communications Security\SSH Secure Shell")

Share this post


Link to post
Share on other sites

; Checks to see if the file exists
If FileExists( "C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe" ) Then MsgBox(0, "", "True") 
; Launches the executable
Run( '"C:\Program Files\SSH Communications Security\SSH Secure Shell\SshClient.exe"', "C:\Program Files\SSH Communications Security\SSH Secure Shell")

This change to the AutoIt script does work on my computer. Were there any changes to the Run() function recently that might cause it to not work?

Share this post


Link to post
Share on other sites

This change to the AutoIt script does work on my computer. Were there any changes to the Run() function recently that might cause it to not work?

Nope, if you have spaces in the path to the exe then you should surround it with quotes like I did or use Run(FileGetShortName("c:\a\long\path\with spaces\in.exe"),"c:\a\long\path\with spaces")

Share this post


Link to post
Share on other sites

Oh yeah. I don't know why I didn't catch that. The spaces do need to be quoted.

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