Send <Ctrl-C> to Command Prompt in TestStand

Updated Dec 1, 2017

Reported In

Software

  • TestStand 2016

Issue Details

Can I send a <Ctrl-C> command from TestStand to close my open command line window? I use this command to close the command prompt on my computer.

Solution

A <Ctrl-C> command cannot be sent directly sent from a TestStand step. 

Possible Workarounds:
1.  Use Window's TerminateProcess Function. On a low level this will not be exactly the same as closing the command prompt with <Ctrl-C> but it should maintain similar sequence functionality.
2. First, create a Call Executable Step.  Second, use File Pathname TASKKILL and the arguments of  "/F /IM cmd.exe /T" to close all cmd Windows.  This is described in this forum post.

Additional Information

A <Ctrl-C> command cannot be executed from TestStand because it requires a ProcessGroupID, but there is no documented way to obtain this value within TestStand.  This ProcessGroupID is explained in greater detail on Microsoft's GenerateConsoleCtrlEvent function API page.