Solved

How to Open an installed program on command?

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

760 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

19 Experts available now in Live!

Get 1:1 Help Now