MSI Factory 2.3

Service.Query

Service.Query

This is the first topic This is the last topic  

Service.Query

This is the first topic This is the last topic  

OverviewExamples

number Service.Query (

string DisplayName,

string KeyName = "" )

Example 1

result = Service.Query("Service1", "");

Queries the service with display name 'Service1' and stores the result in variable 'result'.

Example 2

-- Specify the service to query

ServiceToQueryDisplay = "Service1";

ServiceToQueryKey = "Boom";

 

-- Query the specified service

QueryResult = Service.Query(ServiceToQueryDisplay, ServiceToQueryKey);

if not (QueryResult == SERVICE_RUNNING) then

   -- Set err to 0

   err = 0;

   -- The service is not running.

   if (QueryResult == SERVICE_PAUSED) then

       -- The service is paused, try continue

       Service.Continue(ServiceToQueryDisplay, ServiceToQueryKey);

       err = Application.GetLastError();

   elseif (QueryResult == SERVICE_STOPPED) then

       -- The service is stopped, try start

       Service.Start(ServiceToQueryDisplay, ServiceToQueryKey, nil);

       err = Application.GetLastError();

   end

   if not (err == 0) then

       -- An error happened with Continue/Start

       Dialog.Message("Error (" .. err .. ")", "Unable to start/restart the service.\r\nService is not running");

   else

       Dialog.Message("PERFECTION!", "The service was started/restarted fine.");

   end

else

   -- The service is running

   Dialog.Message("PERFECTION!", "The service is running fine.");

end

Queries the specified service.  If it is running, a dialog is displayed.  If it is not running, it is restarted and either a successful or error dialog is displayed.

See also: Related Actions


Learn More: Indigo Rose Software - MSI Factory - Buy Now - Contact Us