?
Solved

i want to make a program launcher

Posted on 2003-03-01
6
Medium Priority
?
157 Views
Last Modified: 2010-05-01
im so new to visual basic its untrue

i want to make a simple application where i can launch a program from a button

im new to codeing and i was wondering how i would do it

i know its somthing to do with the code under Click() but i dont know how to do it

any help would be cool
if it helps the program i want to run is called soma and its command line is
"c:\soma\soma.exe session.mythofsoma.net"
0
Comment
Question by:sailormars
[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
6 Comments
 

Expert Comment

by:Naylin
ID: 8047010
Easiest way...


Private Sub Command1_Click()
   Shell "c:\soma\soma.exe session.mythofsoma.net", 1
End sub

Note: VB program remains running in the background.
0
 
LVL 3

Expert Comment

by:DocM
ID: 8047012
You can use the Shell Function which runs an executable program and returns a Variant (Double) representing the program's task ID if successful.
Example:
Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1)    ' Run Calculator.
0
 

Accepted Solution

by:
Knarf earned 200 total points
ID: 8047089
Just to clarify the other answers a bit more..

Shell(PathName,WindowStyle)

PathName is the location of the application you want to run

WindowStyle is how you want to window to load.  The following is a list of window styles.

vbHide             0  
Window is hidden and focus is passed to the hidden window.  
vbNormalFocus      1  
Window has focus and is restored to its original size and position.
vbMinimizedFocus   2  
Window is displayed as an icon with focus.
vbMaximizedFocus   3  
Window is maximized with focus.
vbNormalNoFocus    4  
Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus 6  
Window is displayed as an icon. The currently active window remains active.

The Shell() command returns a Double variant which holds the programs Task ID (Also known as PID)
If the operation failed the return value will be 0
0
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!

 

Author Comment

by:sailormars
ID: 8047109
thank you for the help everyone hehe

i couldnt edit the post in time but i would also like to know how to run a website address from a button too


^_^ thanks again
0
 

Author Comment

by:sailormars
ID: 8047113
thank you very much ^_^

0
 
LVL 3

Expert Comment

by:DocM
ID: 8047127

Place the following in the general declarations area of the form.

#If Win32 Then

Private Declare Function ShellExecute Lib _
"shell32.dll" 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

#Else

Private Declare Function ShellExecute Lib _
"shell.dll" _
(ByVal hwnd As Integer, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Integer) As Integer

#End If

Private Const SW_SHOWNORMAL = 1



Private Sub Command1_Click()

Dim iret As Long

' open URL into the default internet browser

iret = ShellExecute(Me.hwnd, vbNullString, _
"http://www.microsoft.com", vbNullString, _
"c:\", SW_SHOWNORMAL)

End Sub
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

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 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…
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

765 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