Solved

How to Open an installed program on command?

Posted on 2004-09-13
5
147 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 39
VBA/SQL - Connect to SQL server and pull data 4 108
How to compare ms sql hashbytes results within vb6 5 73
How to Add / Edit Windows Menu 4 60
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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