system("TASKKILL") Processes With Spaces

I'm writing a program that kills a bunch of processes at once (Windows x64). The main question I have is that I'm trying to figure out how to deal with processes that have spaces in the name. For example in "Creative Cloud Helper.exe". In the console output, I get a message that says "ERROR: Invalid argument/option - 'Cloud.exe'.
Type "TASKKILL /?" for usage.", rather than the process being killed. I don't get this issue with processes that are one word.
The second question I have is how do I find the root process for zombie processes that start themselves?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdlib.h> 
#include <cstdio>
 
int main(){ 

	printf("\n~~~PROCESS KILLER~~~\n");
	printf("\n***Make sure to run in administrator mode.***\n");
	printf("\n");
	printf("\n");

    system("taskkill /IM OriginWebHelperService.exe /F"); 
    system("taskkill /IM NordVPN.exe /F"); 
    system("taskkill /IM Hub.exe /F"); 
    system("taskkill /IM TransportClient.exe /F"); 
    system("taskkill /IM nordvpn-service.exe /F"); 
	system("taskkill /IM CoreSync.exe /F"); 
	system("taskkill /IM Creative Cloud Helper.exe /F"); 
	system("taskkill /IM Adobe Desktop Service.exe /F"); 
	system("taskkill /IM AdobeNotificationClient.exe /F"); 
	system("taskkill /IM CCLibrary.exe /F"); 
	system("taskkill /IM CCXProcess.exe /F"); 
	system("taskkill /IM VirtualDesktop.Service.exe /F"); 
	system("taskkill /IM MMERefresh.exe /F"); 
	system("taskkill /IM vmcompute.exe /F"); 
	system("taskkill /IM Immersed-service.exe /F"); 
	system("taskkill /IM Creative Cloud.exe /F"); 
	system("taskkill /IM AdobeUpdateService.exe /F"); 
	system("taskkill /IM OVRServiceLauncher.exe /F"); 
	system("taskkill /IM Adobe CEF Helper.exe /F"); 
	system("taskkill /IM AdAppMgrSvc.exe /F"); 
	system("taskkill /IM AdskLicensingService.exe /F"); 	
	system("taskkill /IM OVRRedir.exe /F"); 
	system("taskkill /IM OVERServer_x64.exe /F"); 

	printf("\n***END OF LIST***\n");
	printf("\n Press enter to close this window. \n");
	
	printf("\n");
	printf("\n");
	
    std::getchar();
    
    return 0;
} 


Thanks in advance for your help!

Try this:

system("taskkill /IM \"Creative Cloud Helper.exe\" /F");

I assume it was expecting the string of the process name, but it doesn't know where that starts or ends. If quotes are not given, it likely assumes "Creative" is the name then it processes "Cloud" as a keyword which does not exist.
Try say
 
system("taskkill /IM \"Adobe Desktop Service.exe\" /F"); 


> The second question I have is how do I find the root process for zombie processes that start themselves?
Well if they've installed themselves as a service, there will be no background process as such (unless you could svchost.exe).
Similarly, if they've put themselves into the scheduled tasks list, processes will appear at scheduled times (or events).

If you're trying to stop "bad.exe" from running at all, there's not likely to be "bad_parent.exe" somewhere in the background you can just kill off once and be done.
tasklist /svc gives you output like this:

svchost.exe 17776 WdiSystemHost
cmd.exe 18824 N/A

I don't see anything with a chain, but if it won't show chains maybe you can iterate until you get a N/A
oh, I found one:

svchost.exe 1200 BrokerInfrastructure, DcomLaunch, PlugPlay,
Power, SystemEventsBroker
Last edited on
Topic archived. No new replies allowed.