strate Posted February 13, 2006 Share Posted February 13, 2006 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... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 13, 2006 Moderators Share Posted February 13, 2006 (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 Edited February 13, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
strate Posted February 13, 2006 Author Share Posted February 13, 2006 (edited) Is there a question here?Edit:Or is the idea that good that it didn't need a question? j/k 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.exeHow 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 February 13, 2006 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... Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 13, 2006 Share Posted February 13, 2006 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.exeHow 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 resultYou 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). 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 Link to comment Share on other sites More sharing options...
skippynz Posted February 13, 2006 Share Posted February 13, 2006 (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 February 13, 2006 by craig.gill Link to comment Share on other sites More sharing options...
strate Posted February 13, 2006 Author Share Posted February 13, 2006 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... Link to comment Share on other sites More sharing options...
skippynz Posted February 13, 2006 Share Posted February 13, 2006 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. Link to comment Share on other sites More sharing options...
strate Posted February 14, 2006 Author Share Posted February 14, 2006 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... Link to comment Share on other sites More sharing options...
Valuater Posted February 14, 2006 Share Posted February 14, 2006 If I have it such as dir C: will it search another drive?no8) Link to comment Share on other sites More sharing options...
strate Posted February 14, 2006 Author Share Posted February 14, 2006 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... Link to comment Share on other sites More sharing options...
skippynz Posted February 14, 2006 Share Posted February 14, 2006 (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 February 14, 2006 by craig.gill Link to comment Share on other sites More sharing options...
strate Posted February 14, 2006 Author Share Posted February 14, 2006 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... Link to comment Share on other sites More sharing options...
strate Posted February 14, 2006 Author Share Posted February 14, 2006 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... Link to comment Share on other sites More sharing options...
CyberSlug Posted February 14, 2006 Share Posted February 14, 2006 (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 February 14, 2006 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! Link to comment Share on other sites More sharing options...
strate Posted February 14, 2006 Author Share Posted February 14, 2006 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... Link to comment Share on other sites More sharing options...
skippynz Posted February 16, 2006 Share Posted February 16, 2006 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 Link to comment Share on other sites More sharing options...
Confuzzled Posted February 16, 2006 Share Posted February 16, 2006 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now