Execute batch file and keep cmd open
I've written my program to execute a batch file and pass in the needed arguments, however I'm having an issue of trying to figure out how to keep the cmd window open after the batch file has finished executing. I cannot modify the batch file. Originally the way I was performing my task was to add cmd /k at the start of a batch file that would then execute the batch file I was targeting and passing the arguments that way but I'm trying to automate the process more
Currently it's just
9 Replies
try running
cmd.exe
as the FileName
then arguments being /k path.bat
not a bad idea, ill give that a try thank you
@[SK] Cody Are you using the default of
CreateNoWindow=false
and UseShellExecute=false
?i have not set those so i assume yes if they are false by default
no luck
With the following, the application shares the same console output with
cmd.exe
executing the batch.
The application window still opens if you add Console.ReadKey()
.
no dice, heres a small snippet of the function (using WPF), confirmed the constructed string for the arguments is correct. not entirely sure what im missing
Do you want to display the Process' output on a WPF control such as a list box? Or let the output be shown on the cmd window?
For the latter case:
if there is a space in the path you need to quote
uatPath
, otherwise using ArgumentList
IIRC has dotnet do that for youlet it be shown in the CMD window, did the former and did not like the result to much, ill give that a shot