home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2004 April
/
PCWorld_2004-04_cd.bin
/
software
/
temacd
/
remotany
/
RemotelyAnywhere.msi
/
Services.sma
< prev
next >
Wrap
Text File
|
2003-08-19
|
4KB
|
139 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 display all services and drivers on the computer. You can //
// control them via the callback function. //
// //
// 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()
{
new name[64], display[64], bin[64], type, status, startup;
new startstr[5][]={"Boot", "System", "Auto", "User", "Disabled"};
htmlBeginOutput("Services/drivers");
//
// Check whether service enumeration was successful
//
if (raEnumServices()) {
htmlBeginTable("Name", "Display name", "Binary", "Type", "Status", "Startup");
//
// Loop through each service
//
new num=raGetServiceNum();
for (new i=0; i<num; i++) {
htmlBeginTableRow();
raGetService(i, name, display, bin, type, status, startup);
//
// Show service name as a callback
// pass the "tokill" or "tostart" parameter with the
// service name depending on its status
//
htmlBeginTableCell();
htmlCBLink(name, "callb", status==SERVICE_RUNNING ? "tokill" : "tostart", name);
htmlEndTableCell();
htmlTableCell(display);
htmlTableCell(bin);
//
// Check if it's a driver or service
//
if (type<SERVICE_WIN32_OWN_PROCESS) {
htmlTableCell("driver");
} else {
htmlTableCell("service");
}
if (status==SERVICE_RUNNING)
htmlTableCell("running");
else
htmlTableCell("not running");
htmlTableCell(startstr[startup]);
htmlEndTableRow();
}
htmlEndTable();
raEnumServicesClose();
} else {
htmlWrite("Failed to show service/driver list<BR>");
}
htmlButtonBack();
htmlEndOutput();
}
//
// Callback function to start/stop a service
//
public callb()
{
htmlBeginOutput("Service management");
new buf[256], buf2[256];
//
// Check which parameter was filled
//
if (htmlGetParam("tokill", buf)) {
if (raStopService(buf))
sprintf(buf2, "Service \"%s\" stopping...<BR><BR>", buf);
else
sprintf(buf2, "Can't stop service \"%s\"<BR><BR>", buf);
} else if (htmlGetParam("tostart", buf)) {
if (raStartService(buf))
sprintf(buf2, "Service \"%s\" starting...<BR><BR>", buf);
else
sprintf(buf2, "Can't start service \"%s\"<BR><BR>", buf);
}
//
// Show output
//
htmlBeginForm();
htmlBeginDialog("Result");
htmlWrite(buf2);
htmlButton("Back", "main");
htmlWrite("<BR><BR>");
htmlEndDialog();
htmlEndForm();
htmlEndOutput();
}