Check a process is running or not

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Check a process is running or not

Post by alemrantareq » Sun Jan 09, 2011 7:31 am

Hi everybody, I've got a vbscript for checking whether a process is running or not. I'm going to check whether "notepad.exe" is running or not. Here is the vbscript -

Code: Select all

Set WshShell = WScript.CreateObject ("WScript.Shell")
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")

For Each objProcess in colProcessList
If objProcess.name = "notepad.exe" then
vFound = True
End if
Next

If vFound then
msgbox("found")
Else
msgbox("not found")
End If
It works perfect in .vbs mode. Then I've put the above in a btn's custom property. I've just modified this code a little so that rev can work with it. The modified part is -

Code: Select all

If vFound then
result = "Found"
Else
result = "Not Found"
End If
Then made the btn script like this -

Code: Select all

on mouseUp
   do the cVBScript of me as "vbscript"
   put the result into tResult
   answer tResult
end mouseUp
It says

Code: Select all

execution error
As I've no knowledge on vbscript, somebody pls help me correcting the script. I'm waiting for the sound reply & to complete my pending project. Replies r most appreciated. :)

RRobert
Posts: 151
Joined: Sat Feb 28, 2009 8:20 pm

Re: Check a process is running or not

Post by RRobert » Sun Jan 09, 2011 2:34 pm

Set WshShell = WScript.CreateObject ("WScript.Shell")
Set WshShell=CreateObject("WScript.Shell")

Robert

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: Check a process is running or not

Post by alemrantareq » Sun Jan 09, 2011 3:56 pm

Thanks RRobert, That's really works !!! :D

AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Re: Check a process is running or not

Post by AndyP » Sat Jan 15, 2011 11:11 pm

Thanks alemrantareq,

This is a great utility script.
Andy .... LC CLASSIC ROCKS!

chinedukoggu
Posts: 1
Joined: Thu Apr 12, 2012 1:46 pm

Re: Check a process is running or not

Post by chinedukoggu » Thu Apr 12, 2012 2:10 pm

Good day to everyone.

I recently joined this fantastic community and want some guidance regarding livecode.
Similar to the line questioning regarding the monitoring of an application - I wish to create a utility to monitor designated processes or applications via the windows eventlog system.

The requirements are to be able to:
1. List All running services.
2. List all currently running applications
3. Select the appropriate services or applications to be monitored by this utility (via a checkbox)
4. When a level of a particular event occurs such as a warning or an error - a small extract of the warning and the service name is compiled into a short message and sent.

Is there any LiveCode function that currently meets this requirement or do i have to utilize VBscript or powershell to monitor these events and then pass the message .

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Check a process is running or not

Post by Klaus » Thu Apr 12, 2012 5:14 pm

Hi chinedukoggu,

first, welcome to the forum :D
chinedukoggu wrote:...
Is there any LiveCode function that currently meets this requirement or do i have to utilize
VBscript or powershell to monitor these events and then pass the message.
The latter one.

For platform/system-specific tasks always use "shell" (OS X/Windows/Linux) and/or
VB (Windows) or AppleScript (Mac) if possible, VIA LiveCode of course! 8)
LiveCode itself does not provide these special means.


Best

Klaus

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Check a process is running or not

Post by mwieder » Thu Apr 12, 2012 5:15 pm

You may want to read up on the Windows eventtriggers command. And then use LiveCode's shell command to generate the proper triggers and monitor for status results.

http://technet.microsoft.com/en-us/libr ... 10%29.aspx

Post Reply