Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


StartInfo.Arguments for the pscp Process

Posted on 2005-03-07
Medium Priority
Last Modified: 2010-05-18
Hi Experts,

My bat file that does the same thing, contains the following:

z:\Murex\Utils\pscp\pscp.exe -pw "xxxxxxxxxx" -i "C:\Utils\Putty\keys\swartm.ppk" "C:\work\Murex\GL Feed\MURFI_PATH\newDoc.txt" ""

My code is as follows:

string pscpExe = @"z:\Murex\Utils\pscp\pscp.exe";
string passPhrase = "xxxxxxxxxx";
string keyPath = @"C:\Utils\Putty\keys\swartm.ppk";
string destPath = "";

Process pscpProcess = new Process();
pscpProcess.StartInfo.FileName = pscpExe;
filePath = filePath.Replace("\\\\","\\");

string args = "-pw " + "\"" + passPhrase + "\"" + " -i "+ "\"" + keyPath + "\"" + " " +  "\"" + filePath + "\"" + " " +
                    "\"" + destPath +"\"";
pscpProcess.StartInfo.Arguments = args;

When I watch the args parameter, the value is "-pw \"xxxxxxxxxx\" -i \"C:\\Utils\\Putty\\keys\\swartm.ppk\" \"C:\\work\\Murex\\GL Feed\\MURFI_PATH\\gl_JSE 2_15_2005 3_46_59 PM.dat\" \"\"".

But when Start method is called, an exception is thrown: "The system cannot find the file specified."
I think what happens, is that the escape sequences are not interpreted. So, there is a lot of extra slashes in the string.

Does anyone have any ideas how to get this working?
Question by:SCMB-GMIT
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
  • 3
LVL 48

Accepted Solution

AlexFM earned 2000 total points
ID: 13474610
If arguments are wrong, pscp.exe should handle it by it's own way. But you have exception "The system cannot find the file specified." in the Start method, which doesn't care about argument values. I think it cannot find executable file. Try to run the same code without arguments and see what happens.
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13474722
Can you paste here the output of args variable......

string args = "-pw " + "\"" + passPhrase + "\"" + " -i "+ "\"" + keyPath + "\"" + " " +  "\"" + filePath + "\"" + " " +
                    "\"" + destPath +"\"";
System.Console.WriteLine( args );

LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13474734
or by using Debug.Print method

Debug.Print (args)

LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13474745
And pscpExe variable contents also

Debug.Print( pscpExe )
Debug.Print( args )


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

721 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