CMD
-
Hello! i'm rather new to C# and i'd like to ask you if you know how i can send any parameters to the "cmd".For example, if you press start->run and you tipe: cmd /k "ping ip_adress -t -l x_bytes" ... then it starts comand prompt and pinging an adress. The question is how do i send the parameters to the function? I've succeded in opening the cmd process with System.Debug.Process.Start("cmd"); but i don't know how to send parameters. Awaiting your answer... Thank u!:-D
-
Hello! i'm rather new to C# and i'd like to ask you if you know how i can send any parameters to the "cmd".For example, if you press start->run and you tipe: cmd /k "ping ip_adress -t -l x_bytes" ... then it starts comand prompt and pinging an adress. The question is how do i send the parameters to the function? I've succeded in opening the cmd process with System.Debug.Process.Start("cmd"); but i don't know how to send parameters. Awaiting your answer... Thank u!:-D
Simply appending the parameters to cmd should work. Or you can use this[^] overload of the Process class to send the arguments. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Hello! i'm rather new to C# and i'd like to ask you if you know how i can send any parameters to the "cmd".For example, if you press start->run and you tipe: cmd /k "ping ip_adress -t -l x_bytes" ... then it starts comand prompt and pinging an adress. The question is how do i send the parameters to the function? I've succeded in opening the cmd process with System.Debug.Process.Start("cmd"); but i don't know how to send parameters. Awaiting your answer... Thank u!:-D
Hi. The suggested method will work just fine but it has one drawback. You'll need to start a Process for each command, so you'll lose the context if you want to string different commands together. I see two alternatives. For both methods, start a Process for cmd and keep it alive. Then: Alternative 1) Use the Process' input and output streams for sending and receiving data. (simplest would be process.StandardInput.Write and process.StandardOutput.ReadLine). Alternative 2) Use "dirty" win32 techniques such as SetForegroundWindow followed by a SendKeys.Send. PS: If you know a better way for 2) please tell me. It all depends what you are trying to achieve. Cheers Michel