MSI Factory 2.3

Service.Start

Service.Start

This is the first topic This is the last topic  

Service.Start

This is the first topic This is the last topic  

OverviewExamples

Service.Start (

string DisplayName,

string KeyName = "",

table Arguments = nil )

Example 1

Service.Start("StartMe", "", nil);

Starts the service "StartMe".

Example 2

-- specify the service's display name and location

ServiceDisplayName = "Service1";

ServiceFilePath = "C:\\WINDOWS\\SERVICE1.EXE";

 

-- Stop the specified service

Service.Stop(ServiceDisplayName, "");

 

-- Copy the replacement service exe

File.Copy(_SourceDrive.."\\SERVICES\\SERVICE1.EX_", ServiceFilePath, false, true, false, true, nil);

 

-- Start the service

Service.Start(ServiceDisplayName, "", nil);

Stops the specified service, replaces the exe file, and starts the service.

Example 3

-- 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