I am having problems when executing an event in C# using Process.Start. The statement below only outputs half of the command:
private void AddTask_Click(object sender, EventArgs e)
{
Process.Start("schtasks.exe", string.Format(@"/Create /SC DAILY /TN", "\"" + textBox1.Text + "\"", string.Format(@"/TR C:\Program Files\test\scanner.exe C:\", "\"" + textBox1.Text + "\"")));
}
For some reason it cuts of at “/TN” e.g.
“C:\Windows\System32\schtasks.exe” /Create /SC DAILY /TN
Correct. In
The first string is seen as the format string, the rest are arguments, unused in this case.
Without
{0}place holders you don’t needString.Format(), simply useThat doesn’t exclude the possibility of a syntax error in your commandline arguments.
Change it to :
And then you can inspect
argsin the debugger and maybe post here.