chaneu Posted October 10, 2007 Posted October 10, 2007 I need to deploy a script that tests for existence of prg1 on the client and if true then run PRG2 (used to kill the process of PRG1) if false, do nothing.the script is to be deployed as a login script to XP clients in 2000 server domain. The script needs to check every 15 seconds while the user is logged on.summary: check for one process, if it exists kill another.Any ideas?Thanks.chaneu
IcemanND Posted October 11, 2007 Posted October 11, 2007 Something like this should work for you. Found in the scriptcenter repository, http://www.microsoft.com/technet/scriptcen...t.mspx?mfr=truestrComputer = "."Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colMonitoredProcesses = objWMIService. _ ExecNotificationQuery("select * from __instancecreationevent " _ & " within 1 where TargetInstance isa 'Win32_Process'")i = 0Do While i = 0 Set objLatestProcess = colMonitoredProcesses.NextEvent If objLatestProcess.TargetInstance.Name = "notepad.exe" Then objLatestProcess.TargetInstance.Terminate End IfLoop This monitors the processes being created looking specifically for 'notepad.exe' and when it finds it terminates the 'notepad.exe' process. If you want it to run something else replace 'objLatestProcess.TargetInstance.Terminate' with the appropriate code.NOTE: If running this from a login script either put it at the end of the script, or run it as its own script as it will never exit from the loop so the script will never terminate.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now