End Windows processes from within Silk Performer
It is possible to terminate a Windows process using a batch file, and calling that batch file from within Silk Performer. The following code demonstrates this process using the Windows command line utility tasklill.exe.
The contents of the batch file is as follows:
cd c:\windows\system32 taskkill /IM acrord32.exe /f
This file is then saved into Silk Performer as a data file and executed using the ProcessInitialize function.
// Create process and start it up...
hProcessId := ProcessInitialize("command.bat", PROCESS_DETACHED,"", "c:\\", "c:\\out.txt");
// Wait for process to finish.
// Kill the process if it hasn't finished yet - this is referring to the cmd line tool
nStatus := ProcessGetState(hProcessId);
if (nStatus <> PROCESS_STATE_FINISHED) then
// Read the output of the process, written to a file
FOpen(hFile, "c:\\out.txt", OPT_FILE_ACCESS_READ, OPT_FILE_OPEN);
while FRead(hFile, sData, 1, nRead) do
Note: Windows Vista and up may require elevation of privileges for this command to work.