Jump to content

How to run an .exe via AutoIT without knowing the program path?


Recommended Posts

Hi

Can someone maybe help me build an AutoIT, where I can start a program 'example.exe' and the directory is unknown ?

If AutoIT can do it like this from c:\

1. dir example.exe /s /x > c:\fil.txt

This search for the program called example.exe and, if found, puts the path into a file called fil.txt.

2. find "c:\" /i fil.txt

This shows the path where the program is located.

3. Start the program somehow ??

Hope you can help.

Link to post
Share on other sites
  • Moderators

Hi, Traveler. Can you clarify a little bit, so we can better assist?

Are you looking for an interactive script? If so you could use FileOpenDialog from the helpfile to have the user browse for the file and click on it.

If you are looking for a silent execution of the .exe, do you know anything about where it will be? It is much easier to do a system search for the file if you know it'll be somewhere in C:Program Files, vs. could be anywhere on the PC :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

Hi

Sure. The problem is, that I have different places on different PCs, so in advance, I do not know where the program is located. And the AutoIT should be started by the user, and it should run silently untill executed successfully. The program is always located on c:

Link to post
Share on other sites
  • Moderators

Hi, Traveler. You could do something like this (it will give you a start anyway).

#include <array.au3>;
#include <FileListToArrayEx.au3>

$hFilesFolders = _FileListToArrayEx(@ProgramFilesDir, '*.exe')

For $i = 0 To $hFilesFolders
  If Not StringInStr($hFilesFolders[0], "Test1.exe") Then
   _ArrayDelete($hFilesFolders, $i)
  EndIf
Next
Run(_ArrayToString($hFilesFolders), "")

Note: this borrows heavily from SmokeN's great FileListtoArrayEX UDF. You can find that in this thread:

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...