Page 1 of 1

Check a process is running or not

Posted: Sun Jan 09, 2011 7:31 am
by alemrantareq
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. :)

Re: Check a process is running or not

Posted: Sun Jan 09, 2011 2:34 pm
by RRobert
Set WshShell = WScript.CreateObject ("WScript.Shell")
Set WshShell=CreateObject("WScript.Shell")

Robert

Re: Check a process is running or not

Posted: Sun Jan 09, 2011 3:56 pm
by alemrantareq
Thanks RRobert, That's really works !!! :D

Re: Check a process is running or not

Posted: Sat Jan 15, 2011 11:11 pm
by AndyP
Thanks alemrantareq,

This is a great utility script.

Re: Check a process is running or not

Posted: Thu Apr 12, 2012 2:10 pm
by chinedukoggu
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 .

Re: Check a process is running or not

Posted: Thu Apr 12, 2012 5:14 pm
by Klaus
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

Re: Check a process is running or not

Posted: Thu Apr 12, 2012 5:15 pm
by mwieder
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