Process.Start vs. Command line syntax

K

Kevin Vogler

I'm trying to programatically run an app.
The command line syntax is:
"C:\Program Files\WinSCP3\WinSCP3.exe" -script=myscript.txt
and it works as intended.


In code, I have this
Dim myProc As Process = New Process()

myProc.StartInfo.FileName = "C:\Program Files\WinSCP3\WinSCP3.exe"
I've also tried """C:\Program Files\WinSCP3\WinSCP3.exe"""

myProc.StartInfo.Arguments = "-script=myscript.txt"

myProc.Start()



This doesn't work and doesn't produce an error.

What am I doing wrong?

thanks

Kevin Vogler
 
K

kimiraikkonen

I'm trying to programatically run an app.
The command line syntax is:
"C:\Program Files\WinSCP3\WinSCP3.exe" -script=myscript.txt
and it works as intended.

In code, I have this
Dim myProc As Process = New Process()

myProc.StartInfo.FileName = "C:\Program Files\WinSCP3\WinSCP3.exe"
I've also tried """C:\Program Files\WinSCP3\WinSCP3.exe"""

myProc.StartInfo.Arguments = "-script=myscript.txt"

myProc.Start()

This doesn't work and doesn't produce an error.

What am I doing wrong?

thanks

Kevin Vogler

Try this:

Dim p As New Process
Dim info As New ProcessStartInfo _
("C:\Program Files\WinSCP3\WinSCP3.exe", _
"-script=myscript.txt")
p.Start(info)


Hope it works,

Onur Güzel
 
K

Kevin Vogler

Thanks for the quick response.

That doesn't work also.

Maybe I've got this screwed up.

I've been running the command line from the Run command not a terminal
window. Does that make a difference.

Thanks
Kevin


I'm trying to programatically run an app.
The command line syntax is:
"C:\Program Files\WinSCP3\WinSCP3.exe" -script=myscript.txt
and it works as intended.

In code, I have this
Dim myProc As Process = New Process()

myProc.StartInfo.FileName = "C:\Program Files\WinSCP3\WinSCP3.exe"
I've also tried """C:\Program Files\WinSCP3\WinSCP3.exe"""

myProc.StartInfo.Arguments = "-script=myscript.txt"

myProc.Start()

This doesn't work and doesn't produce an error.

What am I doing wrong?

thanks

Kevin Vogler

Try this:

Dim p As New Process
Dim info As New ProcessStartInfo _
("C:\Program Files\WinSCP3\WinSCP3.exe", _
"-script=myscript.txt")
p.Start(info)


Hope it works,

Onur Güzel
 
G

Göran Andersson

Kevin said:
I'm trying to programatically run an app.
The command line syntax is:
"C:\Program Files\WinSCP3\WinSCP3.exe" -script=myscript.txt
and it works as intended.


In code, I have this
Dim myProc As Process = New Process()

myProc.StartInfo.FileName = "C:\Program Files\WinSCP3\WinSCP3.exe"
I've also tried """C:\Program Files\WinSCP3\WinSCP3.exe"""

myProc.StartInfo.Arguments = "-script=myscript.txt"

myProc.Start()



This doesn't work and doesn't produce an error.

What am I doing wrong?

thanks

Kevin Vogler

What do you mean when you say that it "doesn't work"? What happens, and
how does that differ from what you expect?
 
K

Kevin

Thanks for the response.
When I put that command in Start/Run it runs a script that places a file in
a folder via SFTP.

When I put that command in a sub in a vb.net windows app and run it, nothing
happens. No file, no errors thrown.

At this point the myscript.txt file is in the same directory as the
WinSCP3.exe. Do I have to give the absolute path to the myscript.txt since
my app is now running out of my debug folder of my windows app as opposed to
program I'm calling?

I can't try this at the moment because I'm not in the office.

Thanks
Kevin Vogler
 
P

Phill W.

Kevin said:
I'm trying to programatically run an app.

From where? What /sort/ of process?
The command line syntax is:
"C:\Program Files\WinSCP3\WinSCP3.exe" -script=myscript.txt
and it works as intended.
In code, I have this
Dim myProc As Process = New Process()
myProc.StartInfo.FileName = "C:\Program Files\WinSCP3\WinSCP3.exe"
I've also tried """C:\Program Files\WinSCP3\WinSCP3.exe"""

You don't need the quotes - the ProcessStartInfo class will take care of
those for you.
myProc.StartInfo.Arguments = "-script=myscript.txt"
myProc.Start()

Where does that /script/ live? How is WinScp3.exe supposed to find it?

Try setting the .WorkingDirectory property as well (to the directory in
which the script resides).
This doesn't work and doesn't produce an error.

If Process.Start couldn't find the .exe, you'd get an error all
right(!), so that bit /must/ be working; I suspect it's just that the
..exe can't find the script.

HTH,
Phill W.
 
K

Kevin Vogler

Phil,

Thanks the response. It clarified a few things for me. Part of my problem
was the syntax for a console window vs. the Run dialog. Once I sorted it out
in the console window, I was able to get things to work in code.

Thanks again,

Kevin Vogler
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top