Sign in to follow this  
Followers 0
Traveler

Run a program via CMD - program location "unknown"

9 posts in this topic

Hi

Is it possible to call a program via a similar below command, where the actual location of the program is unknown ? I do not know the exact location of the program, because the program has been installed in different ways on different machines during the years.

runWait(@ComSpec & ' /c ' & "programname.exe", @TempDir, @SW_HIDE)

Share this post


Link to post
Share on other sites



I guess, if programname.exe is in the current directory, or the systems path.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

If it is not found via the folders in the path variable then you have to search for it!

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Traveler,

Dredging up my memories of dear departed DOS, I think that will run as long as the app was installed somewhere on the path as set in the environment - or added its path to that variable when installed. :D

If you wanted to be sure that was the case you could run something like this first: :rip:

#include <Array.au3>

; Get an array of the paths in PATH
$aPath = StringSplit(EnvGet("PATH"), ";")

$fFound = False

For $i = 1 To $aPath[0]

    ; Check for a trailing  and add if required
    If StringRight($aPath[$i], 1) <> "" Then
        $aPath[$i] &= ""
    EndIf

    ; Now look for the file on this path
    If FileExists($aPath[$i] & "programmename.exe") Then
        ; We have found it
        $fFound = True
        ExitLoop
    EndIf

Next

If $fFound Then
    MsgBox(0, "", "Found it on " & $aPath[$i])
Else
    MsgBox(0, "", "Not going to run")
EndIf

Any help? :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi

I do not know the location except c: . On my current PC it's c:Program Fileslotusnotesprogramname.exe.

To Melba23, when I run your program I get the message 'Not going to run'.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Traveler,

Look at the RecFileListToArray UDF in my sig - it will find the path for you if you specify the filename. Download it and then run this from the same folder - with the correct "folder" and "programmename" parameters: :oops:

#include <Array.au3>
#include "RecFileListToArray.au3"

$aList = _RecFileListToArray("C:Program Files", "programmename.exe", 1, 1, 0, 2)

_ArrayDisplay($aList)

You should see a list of all instances of the app on that drive. For a big drive it will take a time - so make the "folder" specification as tight as you dare. I have suggested "Program Files" as as a good start point. :rip:

Give it a try and see what you get. :D

M23

Edit: Typnig!

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
If I just enter your new command in a new autoit.exe, then I'm told 'Error: unknown function name'. Maybe I misunderstood, and have to add your new string to your original suggestion ?

Share this post


Link to post
Share on other sites

Traveler,

You need to download the file containing the RecFileListToArray UDF script (just click on the name in my sig and you will go to the thread where the latest version is available) and place it a folder. Create the script I just gave you in the same folder. Then when you run the small script it will find the include file in the same folder and will run - at least it does when I try it! :oops:

A bit of explanation - "including" a file puts its code into the script at that point. So the #include "RecFileListToArray.au3" line is equivalent to you adding all of the UDF code to your script. Clear now? :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

traveler,

1 - somedcomputerguy has given you your answer...

2 - what platform?

3 - the message "not going to run" is probably being issued by your program (not a windows message) and your issue may be applications related

4 - you can use the search facility by right clicking the start key to find any file

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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