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
Page 1 of 1
scripting to test for PRG1 if false run PRG2 deploy a script that test for existence of a prg and kill it.
#2
Posted 11 October 2007 - 06:42 AM
Something like this should work for you. Found in the scriptcenter repository, http://www.microsoft.com/technet/scriptcen...t.mspx?mfr=true
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.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
ExecNotificationQuery("select * from __instancecreationevent " _
& " within 1 where TargetInstance isa 'Win32_Process'")
i = 0
Do While i = 0
Set objLatestProcess = colMonitoredProcesses.NextEvent
If objLatestProcess.TargetInstance.Name = "notepad.exe" Then
objLatestProcess.TargetInstance.Terminate
End If
Loop
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.
- ← [W2k Server]remote desktop problems
- Windows NT4/2000/2003
- help please. installing win2000 on new laptop. no sound →
Share this topic:
Page 1 of 1



Help
Back to top









