Deepak February 2016

how to call exe file in vb6 with multiple parameters

I tried With below code

Dim pthName As String
Dim Parms As String
Dim RpNo As Integer
Dim glngbr As Long
Dim PrtVw As String
pthName = "D:\Sample.exe"
RpNo = 1
PrtVw = "V"
glngbr = 84003
Shell pthName & Parms

I am getting error "Run time error 53 ".

i tried without parameter its working

Shell pthName

Answers


Karthikeyan February 2016

You can use like this,

Shell "D:\Sample.exe" & " " & Param_1, Param_2


alwaysVBNET February 2016

Try this:

Shell "D:\Sample.exe" & " " & RpNo & " " & PrtVw & " " & glngbr


Paco q February 2016

Use the api shellexecute http://support.microsoft.com/kb/238245

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

Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2

private Sub exec_program()
    ShellExecute App.hInstance, "Open", "D:\Sample.exe", "Parms", "C:\", SW_SHOWNORMAL
End Sub


BobRodes February 2016

You don't need to use the Shell command, or ShellExecute either for that matter. There's a simpler solution: the global VBA.Command object contains whatever string you added when you called your exe file. For example, if you enter myproject.exe hello world on the command line, VBA.Command will contain the string hello world.

If you want multiple command line arguments, you can just put them all on the command line separated by a known delimiter such as /. Then you can use the Split function to break them up.

Read This. It will tell you all about it, including how to use it in the IDE without having to test against a compiled version.

Post Status

Asked in February 2016
Viewed 3,603 times
Voted 7
Answered 4 times

Search




Leave an answer