We are creating an automation to read data from a spreadsheet then create a Command Line prompt to call SQLCMD to execute a call to SQL Server. The command reads in a SQL file and outputs to a CSV. The process will eventually do this around 20 times. This part all works fine so far....
However, how in our automation can we close the CMD window after each call has finished? Some of the calls will take quite a while to produce the file, but ideally we'd like to "tidy up" along the way, rather than waiting for the automation to complete before all CMD windows naturally close.
I've attached a view of the automation and cmd line call.
Any help with the automation would be gratefully received.
After SendKeyStringToHostPlusEnter method as per your screenshot, add another SendKeyStringToHostPlusEnter method and it's key values should be "exit". Generally to close command prompt "exit" is the command, above suggestion was to implement the same.
After the SQLCMD have been executed, but still the cmd prompt was not getting killed, if this is the scenario, you may use below C# script to kill the cmd prompt process i.e below code is equivalent to killing cmd prompt from task manager.
You need to provide the process name as in task manager.