Visual Basic Shell Command

I want to use a Shell command in my VB 6.0 application to start an executable.  I want to pass it four parameters.  Is this possible and if so, how would I do it?
PJS123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aelatikCommented:
Shell "c:\yourexe.exe"
0
aelatikCommented:
What exactly do you mean with parameters ?

Like Shell "Yourexe.exe /p=blahblah"
0
sinistershadowCommented:
It's exactly the same way you would pass it parameters in the run dialog.

e.g. To open Windows Media Player with a file you would type:

wmplayer.exe C:/File.wav

into a run dialog box (the '.exe' is not necessary)

In VB6 you do the same thing:

Call Shell("wmplayer.exe C:/File.wav")

Hope that helps.

Sinister Shadow
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

trkcorpCommented:
As previously stated,

Shell("your.exe /parm1 /parm2 /parm3 /parm4")

But then, how do you read the parameters? Well, in your start up code for the target exe (most likely your Sub Main()) use the Command function something like this:

Sub Main()
Dim sArray() as string
If Len(Command) > 0 Then
  sArray = Split(Command, , Space(1), 4)
  MsgBox "Parm 1 Value: " & sArray(0)
  MsgBox "Parm 2 Value: " & sArray(1)
  MsgBox "Parm 3 Value: " & sArray(2)
  MsgBox "Parm 4 Value: " & sArray(3)
End If
End Sub



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richie_SimonettiIT OperationsCommented:
optionally, you could use ShellExecute API:

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


Sub LaunchExe()
shellexceute 0,"open","c:\myfile.exe","parameters goes here",vbnullstring,vbnormal
end sub
0
Richie_SimonettiIT OperationsCommented:
or
Sub LaunchExe(sExePath as string)
shellexecute 0,"open",sExePath,"parameters goes here",vbnullstring,vbnormal
end sub
0
CleanupPingCommented:
Hi PJS123,
This old question (QID 20555209) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
GPrentice00Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->Accept trkcorp's comments as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.