My goal requires a programmatic solution for terminating dotnet.exe when it has a second-chance exception (e.g. using Stop-Process
or taskkill
for termination). Can this be done?
The batch file I was provided has a command like:
dotnet exec Some.Namespace.Project.dll -t
The only alternative I have in mind would be to kill the dotnet.exe process before the second-chance exception. Timing this correctly requires a way to determine when an output file is no longer being modified and/or when a specific string appears in the standard output that indicates processing for the output file is finished.
Please note, I am attempting to automate the solution in a shell language (PowerShell, Bash, or CMD commands), but I will accept solutions in other languages too (e.g. C#, Python, etc.). I have been scripting outside of the batch file I was provided, but I can also edit the batch file itself.