0

hi there i have a text box and a command button in a C# project and i want to access the command prompt with it whenever i input like dir in the textbox and click on the command button the dir will go to the command prompt of windows command prompt and execute the command. Can anyone help? Thanks :)

2
Contributors
1
Reply
3
Views
9 Years
Discussion Span
Last Post by Ramy Mahrous
0

You can use ProcessStartInfo class to help you I am attaching an example it could help

This example I wrote to help me to generate key file for com and com+ applications

public void GenerateKeyFile(string path)
        {
            string commandLine = " \"C:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\Bin\\sn.exe\" -k ";
            ProcessStartInfo PSI = new ProcessStartInfo("cmd.exe");
            PSI.RedirectStandardInput = true;
            PSI.RedirectStandardOutput = true;
            PSI.RedirectStandardError = true;
            PSI.UseShellExecute = false;
            Process p = Process.Start(PSI);
            System.IO.StreamWriter SW = p.StandardInput;
            System.IO.StreamReader SR = p.StandardOutput;
            SW.WriteLine(commandLine + path);
            SW.Close();
        }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.