So when I run the follow function, with
pathToScripts ="C:\\WORKINGDIRECTORY"
batchfiles ="mybatchfile.bat"
Expand|Select|Wrap|Line Numbers
- //----------------------------------------------------------------------------------------------------------
- // ExecuteScript - runs a batch file using cmd.exe with a /k (keep on screen)
- // parameter.
- //----------------------------------------------------------------------------------------------------------
- public static void ExecuteScript(string pathToScripts, string batchfile )
- {
- try
- {
- string sCmd = "C:\\WINDOWS\\system32\\cmd.exe";
- string sTPath = Path.Combine(pathToScripts, batchfile);
- ProcessStartInfo psi = new ProcessStartInfo(sCmd);
- psi.WorkingDirectory = InQuotes(pathToScripts);
- psi.Arguments = " /T:2F /D /K " + InQuotes(sTPath);
- psi.UseShellExecute = true;
- Process cmd = new Process();
- cmd.StartInfo = psi;
- if (!cmd.Start())
- {
- MessageBox.Show("Error", MessageBoxButtons.OK);
- }
- }
- catch (Exception e)
- {
- MessageBox.Show(e.ToString(), " ", MessageBoxButtons.OK);
- }
- }
'mybatchfile_called1.bat' is not recognized as an internal or external command,
operable program or batch file.
'mybatchfile_called2.bat' is not recognized as an internal or external command,
operable program or batch file.
C:\AppPath\MyApp\bin\Release>