nlucci45 Posted October 11, 2014 Share Posted October 11, 2014 Hello, I am very new to scripting but would like to write a script to start an application. I would like to search for the applicaton on the computer the script is run on to find its path and save it as a string that I can use to start the program. Any help would be appreciated. Thanks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 11, 2014 Moderators Share Posted October 11, 2014 nlucci45,Welcome to the AutoIt forums. _FileListToArrayRec will search a drive to find the file - DriveGetDrive will list the drives on the machine if you need to search them all. Give it a go and see how you get on - you know where we are if you run into difficulties. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mikell Posted October 11, 2014 Share Posted October 11, 2014 A search for the app path in the registry should be a little faster Link to comment Share on other sites More sharing options...
nlucci45 Posted October 14, 2014 Author Share Posted October 14, 2014 OK, I went to the help for both _FileListToArrayRec and DriveGetDrive and ran the two example scripts. For the first one I get an array with all the files in the autoIt installation. I tried to search for my filename in the c: path but it didnt work. Remember Im incredibly new here and I am not looking for you guys/gals to do this for me. Just need a little more. mikell - can you elaborate on your approach? thanks in advance for the help... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 14, 2014 Moderators Share Posted October 14, 2014 nlucci45,Running the _FileListToArrayRec example will of course return all the files in the AutoIt installation as that is what the example is supposed to do. What you need to do is use the filename you are searching for as the $sMask parameter - then you will only get that file returned - and you set the root of the drive as the $sFilePath parameter to search the whole thing. So your code would look something like this:#include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> $sFileName = "AutoIt3.exe" ; Just as an example $aDriveList = DriveGetDrive("ALL") ;_ArrayDisplay($aDriveList, "Drives", Default, 8) ; If you want to see what was returned For $i = 1 To $aDriveList[0] ; Test if drive ready If DriveStatus($aDriveList[$i] & "\") = "READY" Then ; Announce which drive we are searching SplashTextOn("Searching", "Drive " & StringUpper($aDriveList[$i]), 300, 100) ; Now search $aList = _FileListToArrayRec(StringUpper($aDriveList[$i]) & "\", $sFileName, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) ; Clear splash SplashOff() ; Display Result If IsArray($aList) Then _ArrayDisplay($aList, "Files on " & $aDriveList[$i], Default, 8) ; If you want to see what was returned ; No point in seaarching further ExitLoop Else MsgBox($MB_SYSTEMMODAL, "Drive " & $aDriveList[$i], "No files found") EndIf EndIf Next ; Announce result MsgBox($MB_SYSTEMMODAL, "Found", $sFileName & " found at " & $aList[1])Please ask if anything is unclear. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jguinch Posted October 14, 2014 Share Posted October 14, 2014 I agree with Mikell. Does the application have an entry in the list of installed programs (Control Panel / Programs and features) ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
nlucci45 Posted October 16, 2014 Author Share Posted October 16, 2014 Melba, That script does what I want. Thanks! I can take $aList[1] and use it as the path to open my exe. Now, next thing if your still out there. How do I save $aList[1] so that I don't have to look for it each time I run the program? Do I store it in a txt file and read it upon execution? If the string isnt there I run your script and find it, if it is there I use whats in the txt file? Thanks so much. And I looked through the Help at all the UDF and macros and didn't find anything that would do what Melba's script does... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 16, 2014 Moderators Share Posted October 16, 2014 nlucci45, How do I save $aList[1] so that I don't have to look for it each time I run the program?I would use an ini file - look at the Ini* functions in the Help file and see if you can get something working. If not post the code you tried (see here how to do it) and we can see what was wrong. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nlucci45 Posted October 17, 2014 Author Share Posted October 17, 2014 (edited) I think using MelbaFindFile() which is your script altered for my program to find the path and IniWriteSection and IniRead will work great. I find the path. Save it in the ini and put it in the programs path. Each time my program is run it checks to see if the applications path has been stored, if so gets the data and uses it to start the exe. I think I will also check to see if the path stored exists. Just in case someone reinstalls the application I am starting with my program. I know with the SSD's coming down I have been doing a bit of that myself. Thanks for the responses. Thanks Melba23 for the help. I have learned so much messing around with autoit that I am looking for other things to do with it. I have NO real coding experience. Its kind of addicting... Edited October 17, 2014 by nlucci45 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