home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2004 April
/
PCWorld_2004-04_cd.bin
/
software
/
temacd
/
remotany
/
RemotelyAnywhere.msi
/
WatchProcess.sma
< prev
next >
Wrap
Text File
|
2003-08-19
|
4KB
|
141 lines
////////////////////////////////////////////////////////////////////////////////
// //
// RemotelyAnywhere Sample 'SMALL' Scripts //
// //
// RemotelyAnywhere provides a mechanism for scripting via a built-in //
// language. The language is called Small, and more information about //
// it can be found at http://compuphase.com/small.htm. //
// //
// Before you use these sample scripts, you should tailor their //
// behavior to better suit your configuration and your needs. //
// //
// This script will check if Notepad is running. It can be run interactively //
// (ie. from the Scripts menu, or can be called from a Monitoring Script. //
// //
// THIS SOFTWARE IS PROVIDED BY 3AM LABS LTD ``AS IS'' AND //
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE //
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE //
// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE //
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL //
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS //
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) //
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT //
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY //
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF //
// SUCH DAMAGE. //
// //
////////////////////////////////////////////////////////////////////////////////
#include <ra>
public main()
{
//
// Do we have HTML output?
//
new outp;
//
// Was the process found?
//
new found = false;
//
// Process Enumeration Variables
//
new pid, name[64], cpu, mem;
//
// The process we are watching
//
new processname[] = "c:\\windows\\system32\\notepad.exe";
//
// Prepare title for HTML page
//
sprintf(name, "Watch for process %s", processname);
//
// Attempt HTML output (will fail if run from the monitoring script)
//
outp = htmlBeginOutput(name);
//
// Enumerate processes
//
if (raEnumProcs()) {
//
// How many are there?
//
new num=raGetProcessNum();
//
// Loop through each process
//
for (new i=0; i<num; i++) {
new tmp[20];
//
// Get process properties
//
raGetProcess(i, pid, name, cpu, mem);
//
// Compare names
//
if (!stricmp(processname, name)) {
//
// Found it!
//
if (outp) {
//
// Report if running in interactive mode
//
sprintf(tmp, "%d", pid);
htmlWrite(processname);
htmlWrite(" is running with process ID ");
htmlWrite(tmp);
htmlWrite(".<BR><BR>");
}
found = true;
break;
}
}
//
// End process enumeration
//
raEnumProcsClose();
}
if (outp) {
if (!found)
{
htmlWrite("Could not find process ");
htmlWrite(processname);
htmlWrite(".<BR><BR>");
}
htmlBeginForm();
htmlButtonBack("Back", false);
htmlEndForm();
htmlEndOutput();
}
//
// Return zero if found, non-zero if not found
//
return !found;
}