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 :)

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();
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.