Search and open an EXE file

sirte

New Member
Joined
May 21, 2003
Messages
13
I need to open one or other exe file if it is installed
If the PC is 32 bit the file will be in C:\Programs Files\myfolder\filename.exe
If the PC is 64 bit the file will be in C:\Programs Files(x86)\myfolder\filename.exe

So far I have tried a combination of the following using the Shell function and failed. please email me if solution found
drilling@maltanet.net
Thanks


Private Sub CommandButton13_Click()

On Error GoTo NoCanDo1

Dim MyAppID, ReturnValue
Dim RetVal
MyAppID = Shell("C:\Program Files\myfolder\filename.exe", 1) ' Run 32 bit 2010 if file found and exit sub.

Exit Sub

NoCanDo1:
On Error GoTo NoCanDo2

Dim MyAppID, ReturnValue
Dim RetVal
ReturnValue = Shell("C:\Program Files (x86)\myfolder\filename.exe", 1) ' Run 64 bit 2010 if file found and exit sub.

Exit Sub

NoCanDo2:


On Error GoTo continue




continue:
UserFormmyfile.Show 'shows a form with details if file not installed


End Sub
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
This code will return you path to file.
Code:
[COLOR="Blue"]Sub[/COLOR] RunProgram()
    
    [COLOR="Blue"]Dim[/COLOR] sFolder [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]String[/COLOR], sFullPath [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]String[/COLOR]
    
    [COLOR="Blue"]If[/COLOR] Len(Environ$(ProgramW6432)) > 0 [COLOR="Blue"]Then[/COLOR]
        sFolder = "Program Files (x86)"
    [COLOR="Blue"]Else[/COLOR]
        sFolder = "Program Files"
    [COLOR="Blue"]End[/COLOR] [COLOR="Blue"]If[/COLOR]
    
    sFullPath = "C:\" & sFolder & "\myfolder\filename.exe"
    
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Function[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top