HACKIS - Hacking Internet Security
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Tuyệt Kỹ Đong Giai Chân Kinh (tuyệt Kỹ cua trai)
Giao tiếp với cmd trong lập trình C#? EmptyThu Aug 23, 2012 5:38 am by Admin

» Tuyệt kỹ cua giai
Giao tiếp với cmd trong lập trình C#? EmptyThu Aug 23, 2012 5:36 am by Admin

» NETCAT.........
Giao tiếp với cmd trong lập trình C#? EmptyMon Aug 13, 2012 6:35 am by Admin

» Bảo mật CSDL bằng phương pháp mã hóa.
Giao tiếp với cmd trong lập trình C#? EmptyTue Apr 17, 2012 10:04 pm by Admin

» Hàm mã hóa MD5 bằng JavaScript
Giao tiếp với cmd trong lập trình C#? EmptyTue Apr 17, 2012 10:03 pm by Admin

» Giá của món quà
Giao tiếp với cmd trong lập trình C#? EmptyFri Apr 13, 2012 6:01 am by Admin

» Sẽ chỉ yêu ai?
Giao tiếp với cmd trong lập trình C#? EmptyFri Apr 13, 2012 6:01 am by Admin

» Cách đọc bảng chữ cái!
Giao tiếp với cmd trong lập trình C#? EmptyThu Apr 12, 2012 10:37 pm by Admin

» Gắn trojan, keylog, virus vào website, forum
Giao tiếp với cmd trong lập trình C#? EmptyTue Apr 10, 2012 1:14 am by Admin

Affiliates
free forum


Giao tiếp với cmd trong lập trình C#?

Go down

Giao tiếp với cmd trong lập trình C#? Empty Giao tiếp với cmd trong lập trình C#?

Post  Admin Sat Oct 22, 2011 8:25 am

public void ExecuteCommandSync(object command)
{
try
{
// create the ProcessStartInfo using "cmd" as the program to be run,
// and "/c " as the parameters.
// Incidentally, /c tells cmd that we want it to execute the command that follows,
// and then exit.
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);

// The following commands are needed to redirect the standard output.
// This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
// Display the command output.
Console.WriteLine(result);
}
catch (Exception objException)
{
// Log the exception
}
}
Admin
Admin
Admin

Tổng số bài gửi : 782
Join date : 2009-08-15

https://hackis.forumvi.com

Back to top Go down

Giao tiếp với cmd trong lập trình C#? Empty Re: Giao tiếp với cmd trong lập trình C#?

Post  Admin Sat Oct 22, 2011 8:26 am

- Cách ngắn hơn thì có thể là như thế này:
Visual C# Code:
Lựa chọn code | Ẩn/Hiện code
string commandToExecute = @"md c:\Test";// @"c:\windows\system32\calc.exe";
System.Diagnostics.Process.Start(@"cmd", @"/c " + commandToExecute);
- Còn cách đầy đủ hơn thì bạn tham khảo ở đây:
http://www.digitalcoding.com/Code-Sn...-from-Net.html
Admin
Admin
Admin

Tổng số bài gửi : 782
Join date : 2009-08-15

https://hackis.forumvi.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum