Page 1 of 1 1
Topic Options
#15865 - 2002-01-08 11:53 PM Running Applications
Lou6969 Offline
Fresh Scripter

Registered: 2001-12-26
Posts: 14
I am looking for a way to determine which applications or services are running at a specific time.

What I will do is write a Kix script that will run or wakeup every 5 minutes to check to see if SQL is running as a service and to see if one other applications is running. If either of these are not running, a notification will be sent to Operations.

Any ideas or suggestions?

Top
#15866 - 2002-01-09 01:38 AM Re: Running Applications
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Lou,

What flavour of machine will this script run under ? NT, 2K ?

-Shawn

Top
#15867 - 2002-01-09 01:56 AM Re: Running Applications
Lou6969 Offline
Fresh Scripter

Registered: 2001-12-26
Posts: 14
Windows 2000 server
Top
#15868 - 2002-01-09 02:13 AM Re: Running Applications
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Checking services on Windows 2000 server ? Coming right up:


Break On


$ServiceName = "EventLog"


$statustypes =
"null",
"Stopped",
"Start Pending",
"Stop Pending",
"Running",
"Continue Pending",
"Pause Pending",
"Paused",
"Error"


$Service = GetObject("WinNT://@WKSTA/$ServiceName,Service")


If $Service
?"Status=" $StatusTypes[$Service.Status]
EndIf


Exit 1

And someone just called me an "OLE has-been" (offline) ... Take that I say !!!

-Shawn

Top
#15869 - 2002-01-09 03:00 AM Re: Running Applications
Lou6969 Offline
Fresh Scripter

Registered: 2001-12-26
Posts: 14
Thanks!

Now do you know how to do this for a running application?

Thanks again,
Lou

Top
#15870 - 2002-01-09 03:15 AM Re: Running Applications
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Running application eh, Windows 2000 Server you say eh ? Coming right up:


Break On


$Process = "Services.Exe" ; What to look for


$Hostname = "@WKSTA" ; Where to look for it


$WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!//$hostname")


$Collection = $WMI.ExecQuery('Select * from Win32_Process Where Name = "$Process"')


If $Collection.Count
?"Found running instance(s) of $Process on $Hostname"
For Each $Process in $Collection
?"Process = " $Process.Name " ThreadCount = " $Process.ThreadCount
Next
Endif


$WMI = 0


Exit 1

Im just funning - there are lots of examples of this stuff on the board here ... hope this helps your cause my friend !

-Shawn

[ 09 January 2002: Message edited by: Shawn ]

Top
#15871 - 2002-01-09 03:31 AM Re: Running Applications
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Lou,

Sorry, I just reposted the above script to properly soften-up the $Process variable

-Shawn

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.096 seconds in which 0.064 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org