Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone please help me with the shell command? 1

Status
Not open for further replies.

osorio

MIS
Jul 8, 2001
7
VE
I wish to make my basic program run another .exe program with a command button. I was told to use the shell command, but I don´t understand the parameters needed to use it. I would be very thankful to anyone willing to give me a brief explanation.
Also, is it possible to integrate one or more .exe programs into one main .exe program, that would run each of these programs when their respective command button is pressed?
Thank you very much.
 
This is an exampe of code executing and openning the program visio. Located on the disk P"
When clicking the commandbutton the program will start as if clicking on the exe file.

Private Sub Command1_Click()
Shell ("p:\visio50\visio32.exe")
End Sub
 
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

Public Function Exec(str As String) As Long
Dim hWnd As Long
Exec = ShellExecute(hWnd, vbNullString, str, vbNullString, vbNullString, vbNormalFocus)

End Function

Then on your code just use:

Exec("C:\.....\yourfile.exe")

Hope this helps
 
Here is yet, a third way:

Private Declare Function WinExec Lib "kernel32" Alias "WinExec" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long


Private Sub Command1_Click()
Dim RunFile As Long
RunFile = WinExec("c:\foldername\yourfile.exe", 1)
End Sub
 
All of the above responses accomplish the task of starting a seperate program from within VB. I have not analyzed the above code so I don't know which way they function, but I want to point out that it is also possible for you to choose whether you want the newley spawned process to run synchronously or asynchronously with your calling app.

As to your question of whether it is "possible to integrate one or more .exe programs into one main .exe program" I must defer you to another thread (Thread222-103449)
In particular, read the response from alt255 (6th post from the top). His answer is yes "it is possible and quite feasible".

I found it to be a very interesting post. Thanks alt255!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top