Sign in to follow this  
Followers 0
Traveler

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

4 posts in this topic

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.

Share this post


Link to post
Share on other sites



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 :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


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:

Share this post


Link to post
Share on other sites

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:


√-1 2^3 ∑ π, and it was delicious!

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