This script verify each 30 seconds if two process are running to a user that opened a application with the script. In case of one process was terminated, then the other process will be terminated.

On Error Resume Next
Set objNet = CreateObject(\”WScript.NetWork\”)
Set WshShell = WScript.CreateObject(\”WScript.Shell\”)

wshshell.run chr(34) & \”C:Program FilesInternet Exploreriexplore.exe\” & chr(34) & \” -k d:WebVisionP.htm\”
processo = \”GUICOMM.EXE\”
processo2 = \”VisionP.EXE\”

Set objWMIService = GetObject(\”winmgmts:{impersonationLevel=impersonate}!.rootcimv2\”)
x=0
do while x<>1
user_processo = \”\”
user_processo2 = \”\”
wscript.sleep 30000
Set colProcessList = objWMIService.ExecQuery (\”Select * from Win32_Process Where Name = \’\” & processo & \”\’\”)
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameofUser)
if ucase(trim(strNameofUser)) = ucase(trim(objNet.UserName)) then
User_processo = strNameofUser
end if
Next
Set colProcessList = objWMIService.ExecQuery(\”Select * from Win32_Process Where Name = \’\” & processo2 & \”\’\”)
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameofUser)
if ucase(trim(strNameofUser)) = ucase(trim(objNet.UserName)) then
User_processo2 = strNameofUser
end if
Next
if Ucase(trim(User_processo2)) <> Ucase(trim(User_processo)) then
Set colProcessList = objWMIService.ExecQuery (\”Select * from Win32_Process Where Name = \’\” & processo & \”\’\”)
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameofUser)
if ucase(trim(strNameofUser)) = ucase(trim(objNet.UserName)) then
objProcess.Terminate()
end if
Next
x =1
end if
loop