Solved

How to Open an installed program on command?

Posted on 2004-09-13
5
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL VB connection works in one PC and doesn't in another 15 80
VB6 ListBox Question 4 63
VB6 - Scroll Mouse wheel on Picturebox 13 122
VBA - If Bookmark = "XXBOOKMARKXX" then 15 67
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

752 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