Solved

How to call .exe from .Net ?

Posted on 2014-09-29
2
192 Views
Last Modified: 2014-09-30
I have to call sfxcl.exe from vb.net by passing paramters. Below syntax works well for .bat file. If i use .bat file instead of .exe , by mentioning the syntax of .exe inside the .bat works fine.

From proc.StartInfo.Arguements, I am getting as

D:/Test.csv,sftp://username:pwd@hostname:22//home/foldera/

Open in new window

But i am expecting as

"D:/Test.csv" sftp://username:pwd@hostname:22//home/foldera/

Open in new window


This syntax works well for batch file execution. Batch file execution takes place in the hidden scenario.
I am trying to have the same feature in the .exe file execution.


 Dim sSFTP As String = String.Empty
            sSFTP = "sftp://" & strUserName & ":" & strPassword & "@" & strHostName & ":" & iPort & strDestPath

            Dim strBatchFile As String = String.Empty
            strBatchFile = "C:\Program Files (x86)\VanDyke Software\Clients\sfxcl.exe"

            Dim proc As New System.Diagnostics.Process()
            proc.StartInfo.UseShellExecute = False
            proc.StartInfo.FileName = strBatchFile
            proc.StartInfo.Arguments = String.Format("{0},{1}", strSourceFile, sSFTP)
            proc.StartInfo.CreateNoWindow = True
            proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
            proc.Start()

Open in new window

0
Comment
Question by:chokka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
chaau earned 500 total points
ID: 40351204
Use this syntax for the Arguments:
 proc.StartInfo.Arguments = String.Format("""{0}"" {1}", strSourceFile, sSFTP)

Open in new window

0
 

Author Closing Comment

by:chokka
ID: 40352152
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question