Solved

How to Open an installed program on command?

Posted on 2004-09-13
5
146 Views
Last Modified: 2010-05-02
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
Comment
Question by:Matrix1000
5 Comments
 
LVL 18

Assisted Solution

by:bobbit31
bobbit31 earned 100 total points
ID: 12049166
Shell "<path to exe>"
0
 
LVL 19

Assisted Solution

by:Shauli
Shauli earned 100 total points
ID: 12049197
Private Sub Command1_Click()
    Shell "X:\program files\myprogram.exe", vbNormalFocus
End Sub

S
0
 
LVL 19

Expert Comment

by:Shauli
ID: 12049202
Yeh, bobbit31 was faster :)

S
0
 
LVL 5

Accepted Solution

by:
KarcOrigin earned 300 total points
ID: 12052210
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
 
LVL 7

Expert Comment

by:_agj_
ID: 12052481
how are u currently opening the exe?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now