जवाबों:
using System.Diagnostics;
class Program
{
static void Main()
{
Process.Start("C:\\");
}
}
यदि आपके आवेदन को cmd तर्कों की आवश्यकता है, तो कुछ इस तरह का उपयोग करें:
using System.Diagnostics;
class Program
{
static void Main()
{
LaunchCommandLineApp();
}
/// <summary>
/// Launch the application with some options set.
/// </summary>
static void LaunchCommandLineApp()
{
// For the example
const string ex1 = "C:\\";
const string ex2 = "C:\\Dir";
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "dcm2jpg.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
}
}
को देखो Process.Start और Process.StartInfo
उदाहरण:
System.Diagnostics.Process.Start("mspaint.exe");
कोड संकलित करना
कोड को कॉपी करें और इसे कंसोल एप्लिकेशन के मुख्य तरीके में पेस्ट करें । "Mspaint.exe" को उस एप्लिकेशन के पथ से बदलें, जिसे आप चलाना चाहते हैं।
Process.Start()
मुझे पता है कि यह अच्छी तरह से उत्तर दिया गया है, लेकिन अगर आप रुचि रखते हैं, तो मैंने एक पुस्तकालय लिखा जो कमांड को निष्पादित करना बहुत आसान बनाता है।
यहाँ देखें: https://github.com/twitchax/Sheller ।
startInfo.UseShellExecute = falseबहुत बढ़िया बात थी ... यह मेरे लिए एक आकर्षण की तरह काम करता था! धन्यवाद! :)