Sign in to follow this  
Followers 0
strate

Find a EXE on any pc?

17 posts in this topic

I'm making a script that will use a program that is installed on the pc. I'm making the script as portable as possible and need it to be able to find where the exe of this particular program is for a run statement.

I'd mention the program but I don't want somebody to do what I am until after I'm done. I wanna see how "good" it is. Afterwards anyone is encouraged to improve it, I just wanna see how much i forget, or how many better ways is possible.

THanks alot.


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm making a script that will use a program that is installed on the pc. I'm making the script as portable as possible and need it to be able to find where the exe of this particular program is for a run statement.

I'd mention the program but I don't want somebody to do what I am until after I'm done. I wanna see how "good" it is. Afterwards anyone is encouraged to improve it, I just wanna see how much i forget, or how many better ways is possible.

THanks alot.

Is there a question here?

Edit:

Or is the idea that good that it didn't need a question? j/k :o

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Is there a question here?

Edit:

Or is the idea that good that it didn't need a question? j/k :o

lol, guess it was never directly asked huh? Here it is.... I'm making the script as portable as possible and need it to be able to find where the exe of this particular program is for a run statement. - Has this been done? How? the exe it needs to find is from another program. Nothing to do with the script.

Example- Excel.exe I may have it installed at H:\Office Apps\Excel.exe you may have it at c:\program files\microsoft\excel\excel.exe

How can I make it so that it searches everything and returns with a path?

Edit: I'll have in it though what it is looking for -excel.exe when it finds that string it gives me a result

Edited by strate

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

lol, guess it was never directly asked huh? Here it is.... I'm making the script as portable as possible and need it to be able to find where the exe of this particular program is for a run statement. - Has this been done? How? the exe it needs to find is from another program. Nothing to do with the script.

Example- Excel.exe I may have it installed at H:\Office Apps\Excel.exe you may have it at c:\program files\microsoft\excel\excel.exe

How can I make it so that it searches everything and returns with a path?

Edit: I'll have in it though what it is looking for -excel.exe when it finds that string it gives me a result

You can just search, but that sounds like the hard way.

If you are looking for Excel, for example, you can check the registry for the program registered to handle .xls files, or .ppt files if looking for PowerPoint, etc. Follow the chain of keys from HKCR\.xls\ for example to see where to look (I'm not on a Windoze box right now, so I can't look).

:o


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

lol, guess it was never directly asked huh? Here it is.... I'm making the script as portable as possible and need it to be able to find where the exe of this particular program is for a run statement. - Has this been done? How? the exe it needs to find is from another program. Nothing to do with the script.

Example- Excel.exe I may have it installed at H:\Office Apps\Excel.exe you may have it at c:\program files\microsoft\excel\excel.exe

How can I make it so that it searches everything and returns with a path?

Edit: I'll have in it though what it is looking for -excel.exe when it finds that string it gives me a result

you could do a dos dir command and read the file it creates to an array and use that ?

dir /s /b excel.exe > excel.txt

that command will return the following line in the txt file

c:\program files\microsoft office\office11\excel.exe --- or wherever your file is located.

edit - or you could use the following - but i dont know if that searches sub directories or not

#include <File.au3>
_FileListToArray($sPath [, $sFilter [, $iFlag]])
Edited by craig.gill

Share this post


Link to post
Share on other sites

Sorry I'm at work right now and the script for this is at home but when I put -dir /s /b excel.exe > excel.txt- in to a runwait it isn't doing it because it is opening the command prompt up at the scriptdir instead of just C: for example.

How can I get it so that it will open properly to c:\> instead of where the script is located c:\AU3> regardless of where the script is?


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

Sorry I'm at work right now and the script for this is at home but when I put -dir /s /b excel.exe > excel.txt- in to a runwait it isn't doing it because it is opening the command prompt up at the scriptdir instead of just C: for example.

How can I get it so that it will open properly to c:\> instead of where the script is located c:\AU3> regardless of where the script is?

you can use the following to set the path to c:\ and then run the command i suggested above

FileChangeDir ( "c:\" )

or change your original code to

dir c:\excel.exe /s /b > excel.txt

from a dos command window i tried the second option and it told me the location of the c:\ execel file.

Share this post


Link to post
Share on other sites

If I have it such as dir C: will it search another drive?


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

If I have it such as dir C: will it search another drive?

no

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Well, that sucks, I guess I'll just have it look for a INI and if its not there have the user set one up. Thnks alot for everyones help.


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Well, that sucks, I guess I'll just have it look for a INI and if its not there have the user set one up. Thnks alot for everyones help.

you could run it a couple of times ie how many drives would you expect the user to have ?

c:\ or d:\ or maybe an e:\ ?

and pipe the text to either the same file using this first

dir c:\excel.exe /s /b > c:\excel.txt

and then

dir d:\excel.exe /s /b >> c:\excel.txt

and then

dir e:\excel.exe /s /b >> c:\excel.txt

or piping to the a different file per drive.

the >> will add to an existing file where > will overwrite the file if it exists already

you could also get autoit to check what local drives are installed on the machine by using this command

$var = DriveGetDrive( "fixed" )
If NOT @error Then
    MsgBox(4096,"", "Found " & $var[0] & " drives")
    For $i = 1 to $var[0]
        MsgBox(4096,"Drive " & $i, $var[$i])
    Next
EndIf

once you have that as a variable you could change the second message box and run the command from there. getting it to change the drive as i said in a previous post then do the dir command.

Edited by craig.gill

Share this post


Link to post
Share on other sites

you could run it a couple of times ie how many drives would you expect the user to have ?

c:\ or d:\ or maybe an e:\ ?

and pipe the text to either the same file using this first

dir c:\excel.exe /s /b > c:\excel.txt

and then

dir d:\excel.exe /s /b >> c:\excel.txt

and then

dir e:\excel.exe /s /b >> c:\excel.txt

or piping to the a different file per drive.

the >> will add to an existing file where > will overwrite the file if it exists already

you could also get autoit to check what local drives are installed on the machine by using this command

$var = DriveGetDrive( "fixed" )
If NOT @error Then
    MsgBox(4096,"", "Found " & $var[0] & " drives")
    For $i = 1 to $var[0]
        MsgBox(4096,"Drive " & $i, $var[$i])
    Next
EndIf

once you have that as a variable you could change the second message box and run the command from there. getting it to change the drive as i said in a previous post then do the dir command.

That is a very good idea thank you very much. I hate setups and this will avoid it.

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

Any ideas why this doesn't work?

Run(@ComSpec & '/c' & 'dir c:\notepad.exe /s /b >> notepad.txt')

Says:

C:\AU3\Run.au3 (1) : ==> Unable to execute the external program.:

Run(@ComSpec & '/c' & 'dir c:\notepad.exe /s /b >> notepad.txt')

The system cannot find the path specified.


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Any ideas why this doesn't work?

Run(@ComSpec & '/c' & 'dir c:\notepad.exe /s /b >> notepad.txt')

Says:

You need a space before and after the /c. Otherwise, everything gets run together.

MsgBox(0,"DEBUG", @ComSpec & ' /c ' & 'dir c:\notepad.exe /s /b >> notepad.txt')

Run(@ComSpec & ' /c ' & 'dir c:\notepad.exe /s /b >> notepad.txt')

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

You need a space before and after the /c. Otherwise, everything gets run together.

MsgBox(0,"DEBUG", @ComSpec & ' /c ' & 'dir c:\notepad.exe /s /b >> notepad.txt')

Run(@ComSpec & ' /c ' & 'dir c:\notepad.exe /s /b >> notepad.txt')

Thank you, I would have never pry caught that. It runs but it doesn't create the file. If I run cmd on my own it will create the file. Is there a solution for this?

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

Thank you, I would have never pry caught that. It runs but it doesn't create the file. If I run cmd on my own it will create the file. Is there a solution for this?

runs ok for me. using this

Run(@ComSpec & ' /c ' & 'dir c:\notepad.exe /s /b >> notepad.txt')

it creates the file in the scriptdir if you dont do the FileChangeDir command first

Share this post


Link to post
Share on other sites

I'm making a script that will use a program that is installed on the pc. I'm making the script as portable as possible and need it to be able to find where the exe of this particular program is for a run statement.

I'd mention the program but I don't want somebody to do what I am until after I'm done. I wanna see how "good" it is. Afterwards anyone is encouraged to improve it, I just wanna see how much i forget, or how many better ways is possible.

THanks alot.

You want us to guess what program you are going to run, improve on the code you are going to write, and then wait for criticism on why your code is better than ours?

Sorry, my crystal ball is in for repairs right now. :o

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