MSFN Forum: scripting to test for PRG1 if false run PRG2 - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

scripting to test for PRG1 if false run PRG2 deploy a script that test for existence of a prg and kill it. Rate Topic: -----

#1 User is offline   chaneu 

  • Group: Members
  • Posts: 3
  • Joined: 04-October 07

Posted 10 October 2007 - 02:22 PM

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


#2 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,249
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

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

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.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy