الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

dos command

مغلق
بدأه mufic_semsem في 19 مايو 2006 · 3 رد · 669 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

how to write a dos command in c# i do it in c like

system("dir");

how in c# pls fast

لا اله الا الله .......................................... محمد رسول الله

#3

الف شكر يا معتز بية

لا اله الا الله .......................................... محمد رسول الله

#4

System.Process.Start("cmd.exe","/c --commandName--");

example

System.Diagnostics.Process.Start("cmd","/c netstat -ano");

System.Diagnostics.Process.Start("cmd","/c dir/p");

but

for commands that run in the MS-Dos ,they are executed so fast then the command window disappears,and i can't watch the result

do u have a soultion

here is the solution:

Process p = new Process();

p.StartInfo.FileName = "cmd";

p.StartInfo.Arguments = "/c netstat -ano";

p.StartInfo.CreateNoWindow = true;

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardInput = true;

p.Start();

//get the output from cmd

string output = p.StandardOutput.ReadToEnd();

//save the output to a file

StreamWriter sw = new StreamWriter(@"C:\fff.txt");

sw.Write(output);

sw.Close();

fs.Close();

هذا الموضوع مغلق.

مواضيع مشابهة