Jump to content

Run a program via CMD - program location "unknown"


Traveler
 Share

Recommended Posts

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)

Link to comment
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...