Hi I needed to make a reference to a path as below. But it seems the space in Program Files trips it. How do I fix this? Note there is no issues when the foldernames are without spaces like in my second example.
not working:
string command = String.Format (@"C:\Program Files\IBM\SQLLIB\myfile.ba
t {0} {1}", "testparam1", "testparam2");
woking:
string command = String.Format (@"C:\MyDocuments\Assignme
nts\AdHoc\
myfile.bat
{0} {1}", "testparam1", "testparam2");
Full code:
System.Diagnostics.Process
ps = new System.Diagnostics.Process
();
System.Diagnostics.Process
StartInfo psinfo = new System.Diagnostics.Process
StartInfo ();
psinfo.FileName =@"C:\Program Files\IBM\SQLLIB\BIN\db2cm
d.exe";
string command = String.Format (@"C:\Program Files\IBM\SQLLIB\myfile.ba
t {0} {1}", "testparam1", "testparam2");
psinfo.Arguments = "/W " + command;
psinfo.UseShellExecute = false;
psinfo.CreateNoWindow = true; // try both true or false
psinfo.RedirectStandardOut
put = true;
psinfo.RedirectStandardOut
put = true;
ps.StartInfo =psinfo;
bool val = ps.Start ();
ps.WaitForExit ();
int exitcode = ps.ExitCode;
ps.Close ();
Start Free Trial