tags:

views:

31

answers:

2

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim p As New ProcessStartInfo
p.FileName = "D:\c\File_copy_program.exe"
p.Arguments = "D:\c\File_copy_program.exe" & "D:\PE.nrg" & "D:\c\1.nrg"
p.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(p)

End Sub

As you may see in the Above Code i am trying to run a program called File_copy_program.exe, which i created using C++. Now this program takes 3 Arguments in Main (i.e. program name, source file, target file).

Now the line: p.Arguments = "D:\c\File_copy_program.exe" & "D:\PE.nrg" & "D:\c\1.nrg"

is not working. And my program says invalid number of arguments passed (since i have a condition in it to make sure the program aborts if number of arguments are not equal to 3).

+1  A: 

Try p.Arguments = "D:\PE.nrg" & " " & "D:\c\1.nrg" - it's doubtful you need to specify the application name as it'll be passed through automagically by DOS, and you need a space between your parameters.

Will A
+2  A: 

You need to pass in the arguments as you would pass them to the program on the command line:

p.Arguments = "D:\PE.nrg D:\c\1.nrg"

Or, if using variables:

p.Arguments = arg1string & " " & arg2string

As you can see from the first example, you don't pass in the program name as an argument, the same way that you would not follow the program name with itself again on the command line.

Oded
And w/o the program.exe
Henk Holterman
@Henk Holterman - fair enough. I thought that with the first example that was clear enough, but possibly not to everyone. Added more information to answer.
Oded
Thanks :) It did the trick in the 1st Method!!
strut