Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

How to Open an installed program on command?

I have a program/exe installed on a server that is accessable from a client machine.
On the client machine the drive and is mapped to X:\ drive. The exe is in X:\program files\myprogram.exe.

I'm using VB6
I want to open the program from the client machine using a command button on a form so the user can just click that button and open the application.

Usually I do on button click C:\program files\the-program-I-want.exe  but this program doesn't seem to like that.
It opens the program ok but then the myprogram.exe crashes.
If I create a shortcut to myprogram.exe on my desktop and double click it, myprogram.exe opens just fine!

What could be causing this...any code would be appreciated :)
0
Matrix1000
Asked:
Matrix1000
3 Solutions
 
bobbit31Commented:
Shell "<path to exe>"
0
 
ShauliCommented:
Private Sub Command1_Click()
    Shell "X:\program files\myprogram.exe", vbNormalFocus
End Sub

S
0
 
ShauliCommented:
Yeh, bobbit31 was faster :)

S
0
 
KarcOriginCommented:
Use ShellExecute API and try this:

Add this in the module-

Option Explicit

Public Declare Function ShellExecute Lib "shell32" _
    Alias "ShellExecuteA" _
   (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long


Public Const SW_SHOWNORMAL = 1

Add this on the form level:-

Private Sub Command1_Click()

    Call ShellExecute(0&, "Open", _
                                 "z:\SocketClient\prjSocket.exe", "/e,/n", _
                                 0&, SW_SHOWNORMAL)

End Sub

In this case my mapped drive is "z:\" and the exe name is prjSocket.exe. I hope it will help and solve your problem.

Cheers!
0
 
_agj_Commented:
how are u currently opening the exe?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now