Jump to content

Run command basic question


Recommended Posts

Hello,

I'm new to AutoIT and have a very basic question about the Run command.

I'm using Windows98SE and AutoIT3 simple mouse action scripts I make are working fine, but

I create a new script and put in the single line:

Run("Wordpad.exe", "C:\Program Files\Accessories\")

but it does not work (error message says system cannot find the specified file)

Whereas this line does work:

Run("Notepad.exe", "C:\WINDOWS\")

I cannot seem to get most programs to start with scripts like this (not sure why notepad does).

Also I tried from a suggestion on the forum

ShellExecuteWait("C:\Program Files\Accessories\Wordpad.exe")

and that does open Wordpad

So what am I doing wrong? A syntax error?

Thanks for any ideas about this.

Link to comment
Share on other sites

  • Developers

You need to specify the full path in the first parameter when the program isn't in one of the "PATH" directories.

The second parameter is the WorkDir NOT the search dir!

Run("C:\Program Files\Accessories\Wordpad.exe")
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks for your help Jos.

I do not know the difference between search directory and working directory.

Okay I see from what you posted that we just need to enter the whole path to the exe.

Note: I think the helpfile could be updated and more clear here for beginners since, when it says filename, I think it may be referring to the whole path too...whereas in the helpfile under the run function (and in the notepad tutorial) the example given for filename is simply Notepad.exe"...kind of confusing for those of us just starting with it.

Okay, that's working fine now except for this:

When I run this line

Run("C:\test.kp")

I wonder why I get this error message

Error: Unable to execute the external program

%1 is not a valid Win32 application

When I just click on the test.kp file it runs fine, but I cannot get the script to open it with this one and only line in the script:

Run("C:\test.kp")

(By the way the .kp file is a Keykit file, and Keykit is an excellent midi music program.)

I'm beginning to think that the .kp file might be associated with the Keykit program in a way that does not let the script run it somehow....I mean the %1 in the error message is a clue...I remember seeing a %1 a while back when I was creating some file associations at folder options> filetypes, etc...hmmmm...I don't know...

A while back I created the association of .kp files to keykit.exe by just putting in the path to keykit.exe

C:\KeyKit7.6e\bin\key.exe with no %1 or anything like that at filetype> new type> action> open etc (Winodws 98SE)...and it works fine to make it so I can click on .kp files and have Keykit.exe open them...

Any ideas about what that %1 in the error message might refer to?

EDIT: by the way

ShellExecuteWait("C:\test.kp")

does work...I'm not sure why

Thank you very much.

Edited by frew
Link to comment
Share on other sites

  • Developers

Run will only run real programs.To "run" the associated program for a file you can use ShellExecute() or Run(@comspec & " /c C:\test.kp")

The working Directory is the default (home) directory for the program when running.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Okay, thanks so much Jos and KentonBomb for the ShellExecute idea.

So I think I'm all set for a while using

Run() to run programs, and

ShellExecute() to "run" files that are associated with programs.

That clears things up nicely. Seems to be working fine now.

Your help is much appreciated. Thank you.

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...