Question

i have a file in "C:\Documents and Settings\Administrator\Application Data\" with name Protector-(random 4 letters).exe . so you can see that the name of the file is random.

now i want to write a c++ code to kill this file's process. plz tell me that code to kill this file. i found ShellExecute() function to run a command (taskkill) and kill the process but i dont know how i can kill a process with random name by this function! this is a code that i found for ShellExecute():

ShellExecute(NULL, L"open", L"C:\\WINDOWS\\system32\\cmd.exe ", L"taskkill /f /fi ""IMAGENAME eq Protector-(random 4 letters).exe""", NULL, SW_SHOWNORMAL); 
Was it helpful?

Solution

See Taskkill /?

Taskkill supports the Wildchar * character

ShellExecute(NULL, L"open", L"C:\\WINDOWS\\system32\\cmd.exe", L"taskkill /f /im \"Protector-*\"", NULL, SW_SHOWNORMAL);

OTHER TIPS

you can do something like 'ps aux | grep Protector' and that should isolate your process. But make sure you don't have anything else by the name Protector in it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top