I’ve got the following code to end a process, but I still receive an error code 2 (Access Denied).
strComputer = '.' Set objWMIService = GetObject('winmgmts:\\' & strComputer & '\root\cimv2') Set colProcessList = objWMIService.ExecQuery('SELECT * FROM Win32_Process WHERE Name = 'MSSEARCH.exe'') For each objProcess in colProcessList wscript.echo objProcess.processid intrc = objProcess.Terminate() if intrc = 0 then wscript.echo 'succesfully killed process' else wscript.echo 'Could not kill process. Error code: ' & intrc End if
It’s quite legitimate to get ‘access denied’ for ending a program. If it’s a service (which I’m guessing mssearch.exe is), then it is probably running as the ‘SYSTEM’ user, which has higher privileges than even the Administrator account.
You can’t log on as the SYSTEM account, but you could probably write a service to manage other services…