Open .exe without Shell (1 Viewer)

kevnaff

Member
Local time
Today, 09:42
Joined
Mar 25, 2021
Messages
141
You can use this code also :
Code:
Public Declare PtrSafe Function FileProtocolHandler Lib "url.dll" _
      Alias "FileProtocolHandlerA" (ByVal hwnd As Long, ByVal hinst As Long, _
      ByVal lpszCmdLine As String, ByVal nShowCmd As Long) As Long

Public Sub OpenHyperlink(ByVal Url)
  FileProtocolHandler 0, 0, Url, 1
End Sub
And call it this way :
Code:
OpenHyperlink "H:\QA90PRO32\QA90PRO.exe"


Hi Moosak,

I've given this a go and I'm not sure that I've copied the code to the correct places.

I created a new module and copied the top section of code.

I then copied OpenHyperlink "H:\QA90PRO32\QA90PRO.exe" in to the on click event of my command button.

When clicking the command button nothing happens.

Have I copied the code to the correct place?

Thanks
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:42
Joined
Sep 12, 2006
Messages
15,656
Hi theDBguy,

I used the following code:

Code:
Dim myPath As String

myPath = "H:\QA90PRO32\QA90PRO.exe"
Application.FollowHyperlink myPath

and got this message:

View attachment 102798

When clicking OK I get this:

View attachment 102799

When clicking debug the following is highlighted:

View attachment 102800
The trouble is probably that you are trying to open an application - and not open a document (such as a pdf) that HAS an associated application. I thought that might happen, to be honest, as your problem was to open a program without using shell. You should error trap the statement, but that doesn't solve the issue.
 

Moosak

New member
Local time
Today, 09:42
Joined
Jan 26, 2022
Messages
26
When clicking the command button nothing happens.
Nothing will happen if the file is not exists.
Check that first and make sure the path is written correctly.
 

Moosak

New member
Local time
Today, 09:42
Joined
Jan 26, 2022
Messages
26
You can try this one also :
Code:
Public Sub OpenPath(strPath As String)
Shell "explorer.exe" & " " & strPath, vbNormalFocus
End Sub
and call it like this :
Code:
OpenPath "H:\QA90PRO32\QA90PRO.exe"
 

Users who are viewing this thread

Top Bottom