How will I pass argument to Process
-
Hi, I am using the following code
Process pr = new Process(); pr.StartInfo.FileName = "SCHTASKS.exe"; // pr.StartInfo.CreateNoWindow = true; // pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Arguments = "/Delete " + ScheduleName;
when I pass the delete argument in command prompt a confirmation will appear. After pressing "y" it the schedule is deleted successfully. I want to pass "y" as arguments but don't know how because I am already passing delete command in arguments If any one can help me. Regards -
Hi, I am using the following code
Process pr = new Process(); pr.StartInfo.FileName = "SCHTASKS.exe"; // pr.StartInfo.CreateNoWindow = true; // pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Arguments = "/Delete " + ScheduleName;
when I pass the delete argument in command prompt a confirmation will appear. After pressing "y" it the schedule is deleted successfully. I want to pass "y" as arguments but don't know how because I am already passing delete command in arguments If any one can help me. RegardsNaveed727 wrote:
a confirmation will appear
There is no reliable way to do that, unless the program you are starting is rewritten to accept another command line parameter to suppress prompts. You could try writing to the process's input stream - check out Process.StandardInput[^]
Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro
-
Hi, I am using the following code
Process pr = new Process(); pr.StartInfo.FileName = "SCHTASKS.exe"; // pr.StartInfo.CreateNoWindow = true; // pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Arguments = "/Delete " + ScheduleName;
when I pass the delete argument in command prompt a confirmation will appear. After pressing "y" it the schedule is deleted successfully. I want to pass "y" as arguments but don't know how because I am already passing delete command in arguments If any one can help me. RegardsHi, I am assuming SCHTASKS is a regular console application, that produces some output (a prompt) in the console or DOS window, and takes some input from there as well. The easy solution, if provided, is by passing another switch; try "SCHTASKS -h" to see its help. If no extra switches are available, you should be able to do it with standard stream redirection; have a look at the Process class, StandardInput/StandardOutput properties, and OutputDataReceived events. You probably need to redirect the output (so you can wait for the confirmation prompt to arrive), AND redirect the input stream, so you can writeline "Y" to it. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.