namespace RunBatchFile { class Program { static void Main(string[] args) { RunCalculator(); } public static void RunCalculator() { //this is the path the document or in our case batch file will be placed string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //this is the path process.start usues string path1 = docPath + "\\Test.bat"; string[] lines = { "@echo off", //"REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\AppCompatFlags //\\Layers", "calc.exe" }; //this writes the string to the file using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath, "test.bat"))) { //This writes the file line by line foreach (string line in lines) outputFile.WriteLine(line); } System.Diagnostics.Process.Start(path1); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)