Expertise in Action: Top-Tier Professional I Services at Your Fingertips

Expertise in Action: Top-Tier Professional I Services at Your Fingertips

Anthony Lv8

Expertise in Action: Top-Tier Professional I Services at Your Fingertips

Table of Contents

Disclaimer: This post includes affiliate links

If you click on a link and make a purchase, I may receive a commission at no extra cost to you.

IServices

https://techidaily.com

Declaration

IServices : IDispatch

Overview

This interface is meant to add new service operation or delete/edit the existing ones.

Properties

Array ServiceOperations - Gets the collection of project service operations.

Methods

NewServiceInstallOperation(IFile aServiceSourceFile) returns IServiceInstallOperation
Creates a new service install operation. Automatically adds a service control operation for the new service.

NewServiceControlOperation(String aServiceName) returns IServiceControlOperation
Creates a new service control operation.

NewServiceConfigureOperation(String aServiceName) returns IServiceConfigureOperation
Creates new service configure operation.

NewServiceFailureOperation(String aServiceName) returns IServiceFailureOperation
Creates new service configure operation.

DeleteServiceOperation(IBaseServiceOperation aOperation)
Deletes a service operation.

https://techidaily.com

Example

$advinst = new-object -com AdvancedInstaller
$prj = $advinst.LoadProject(“D:\services.aip”)

Add new service install operation

$serviceInstall = $prj.Services.ServiceOperations | where {$.Name -eq “MyService” -and $.OperationType -eq “Service Install”}[0]

if($serviceInstall -eq $null)

$serviceExe = $prj.FilesComponent.Files | where {$_.Name -eq “MyService.exe”}[0]
if($serviceExe -eq $null)

  $serviceExe = $prj.FilesComponent.AddFileS("appdir", "D:\my_app_folder\MyService.exe")

$serviceInstall = $prj.Services.NewServiceInstallOperation($serviceExe)
$serviceInstall.Name = “MyService”

$serviceInstall.AllowDesktopInteraction = $true
$serviceInstall.Arguments = “/Run”
$serviceInstall.StartType = “OnDemand”

$serviceConfig = $prj.Services.ServiceOperations | where {$.Name -eq “MySecondService” -and $.OperationType -eq “Service Configuration”}[0]
if($serviceConfig -eq $null)

$serviceConfig = $prj.Services.NewServiceConfigureOperation(“MySecondService”)

$serviceConfig.ConfigureOnInstall = $true
$serviceConfig.ConfigureOnReinstall = $true
$serviceConfig.ConfigureOnUninstall = $false
$serviceConfig.SettingToChange = “TimeToRunFailureActions”

$serviceFail = $prj.Services.ServiceOperations | where {$.Name -eq “MySecondService” -and $.OperationType -eq “Service Failure”}[0]
if($serviceFail -eq $null)

$serviceFail = $prj.Services.NewServiceFailureOperation(“MySecondService”)

$serviceFail.ConfigureOnInstall = $true
$serviceFail.ConfigureOnReinstall = $true
$serviceFail.ConfigureOnUninstall = $false
$serviceFail.DaysBeforeResetFailureCount = 1
$serviceFail.RebootMessage = “”

$failureAction = $serviceFail.FailureActions | where {$_.Action -eq “RunProgram”}[0]
if($failureAction -eq $null)

$failureAction = $serviceFail.NewFailureAction(“RunProgram”, 1)

$serviceFail.RunProgram = “MySecondService.exe”
$serviceFail.RunProgramArguments = ‘/log “MySecondService has stopped.”‘

$prj.Save()

Copy
https://techidaily.com

See also

IBaseServiceOperation

IServiceInstallOperation

https://techidaily.com

Topics

Did you find this page useful?

Please give it a rating:

Thanks!

Report a problem on this page

Information is incorrect or missing

Information is unclear or confusing

Something else

Can you tell us what’s wrong?

Send message

Also read:

  • Title: Expertise in Action: Top-Tier Professional I Services at Your Fingertips
  • Author: Anthony
  • Created at : 2024-10-06 01:20:32
  • Updated at : 2024-10-11 05:51:24
  • Link: https://fox-shield.techidaily.com/expertise-in-action-top-tier-professional-i-services-at-your-fingertips/
  • License: This work is licensed under CC BY-NC-SA 4.0.