| | | Forum Newbie
       
Group: Forum Members Last Login: 11/11/2008 4:16:37 PM Posts: 3, Visits: 15 |
| I'm in search of a WUG v12.0 monitor I can use, import, create, etc that will trigger email alert notifications if/when multiple instances of an application are launched. To further complicate the matter the application I need to perform this monitoring for is a Java app thus the process name will only appear as java.exe. The reason this complicates things is because there are other (totally different) java apps that also run on the same machine. WUG will have to be able to differentiate the various apps running under java.exe.
I have a VBScript (http://windowsitpro.com/Files/07/37748/Listing_04.txt) that when executed checks for multiple instances of the .exe you specify in the command line syntax. I've tested the script itself and it works. When ran if it identifies more than one instance of the specified app it generates a pop-up window that notifies the user that an instance is already running (Note: It does not prevent the execution of the additional instance, it only generates the pop-up). While the script as well as the pop-up message runs as wscript.exe. How could I use this script to trigger alert notifications?
The script referenced above is below:
Option Explicit
Stop
On error Resume Next
'==================
'Declarations
'==================
Dim user,domain
Dim wshShell
Dim strUserName
Dim loc
Dim svc
Dim proc_list
Dim proc
Dim ret
Dim oArgs
Dim Program
Dim Target
Dim Start
'==================
'Main Body
'==================
Set oArgs =WScript.Arguments
set loc = createObject("WbemScripting.SWbemLocator")
Set wshShell = CreateObject("Wscript.Shell")
Program = oArgs(0)
Target = oArgs(1)
strUserName = wshShell.ExpandEnvironmentStrings("%Username%")
loc.security_.impersonationLevel = 3 'impersonate
set svc = loc.connectServer(".","root\cimv2")
set proc_list = svc.ExecQuery("Select * from Win32_Process")
for each proc in proc_list
ret = proc.GetOwner(user,domain)
if ret <> 0 then
'wscript.echo "Error executing GetOwner for process " & proc.Name & " ,Error value = " & ret
Else
If proc.name = Program then
If strUserName = user then
MsgBox user & " is already running " & Program & " ... You cannot open another
instance",vbexclamation,"Warning"
WScript.quit
End If
End If
end if
next
start = WshShell.run(Target)
Any assistance would be greatly appreciated.
Roderick
Roderick
WhatsUp Gold v11 Premium
Windows 2003 Standard SP2 |
| |
|
|