Hello!!!
I want to execute a command from c# as if it was executed from the
command prompt...
how can I do that?
thanks!!
:wave:
Printable View
Hello!!!
I want to execute a command from c# as if it was executed from the
command prompt...
how can I do that?
thanks!!
:wave:
VB Code:
Dim psi As ProcessStartInfo = New ProcessStartInfo("cmd.exe") psi.RedirectStandardOutput = True psi.RedirectStandardInput = True psi.UseShellExecute = False psi.CreateNoWindow = True Dim p As Process = Process.Start(psi) p.StandardInput.WriteLine("ren c:\a.txt b.txt") p.StandardInput.WriteLine("exit")
PHP Code:ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");
psi.RedirectStandardOutput = True;
psi.RedirectStandardInput = True;
psi.UseShellExecute = False;
psi.CreateNoWindow = True;
Process p = Process.Start(psi);
p.StandardInput.WriteLine("ren c:\a.txt b.txt");
p.StandardInput.WriteLine("exit");
well, that's great for vb and php developers... but what about c#?
That is for C#. In PHP tags. For color formatting. Forgive my transgression.
do I need to add a "using" reference for ProcessStartInfo?
because it doesn't reognise it...
:wave:
Use System.Diagnostics
thanks mendhak!!!!
Good. Now add [Resolved]
Bear in mind that if its just a single command you can tag it onto the end of the call to start "cmd.exe" .
hey penagate! how do I do that in code?
I mean, use the start command??
:wave:
Process.Start(appPath, argString);
e.g.
Process.Start("cmd", @"ren c:\a.txt b.txt");
Quote:
Originally Posted by mendhak
Hello. Im trying to do the same thing but with a telnet window.
Telnet will not allow you to redirect the standard IO
Can you please tell me how I can send commands to the telnet without using sendkeys.send()?
Maybe you could look at my thread
http://www.vbforums.com/showthread.php?t=380589
well mendhak, it doesn't work after all...
I just tried it for the first time and it faild...
sorry...
maybe I need to add an "Enter" key after each line?
thanks
:wave:
A 'writeline' includes an 'enter'. It sends the whole command.Quote:
Originally Posted by dekelc
What failed, what did you get instead?
ok... It's working! thanks!
but is there a way to know if my commands succeeded?
:wave: