ServiceProcessInstaller クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ServiceProcessInstaller クラスの意味・解説 

ServiceProcessInstaller クラス

ServiceBase を拡張するクラスを含む実行可能ファイルインストールます。このクラスは、サービス アプリケーションインストール時に InstallUtil.exe などのインストール ユーティリティ呼び出されます。

名前空間: System.ServiceProcess
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文構文

Public Class ServiceProcessInstaller
    Inherits ComponentInstaller
Dim instance As ServiceProcessInstaller
public class ServiceProcessInstaller : ComponentInstaller
public ref class ServiceProcessInstaller :
 public ComponentInstaller
public class ServiceProcessInstaller extends
 ComponentInstaller
public class ServiceProcessInstaller extends
 ComponentInstaller
解説解説

ServiceProcessInstaller は、実行可能ファイル内のすべてのサービスに対して同じ作業行います。このクラスは、インストール ユーティリティで、インストールするサービス関連付けられたレジストリ値を書き込むために使用されます。

サービスインストールするには、Installer から継承するプロジェクト インストーラ クラス作成し、そのクラスの RunInstallerAttribute を true設定しますプロジェクト内では、サービス アプリケーションごとに 1 つServiceProcessInstaller インスタンス、およびアプリケーション内のサービスにつき 1 つの ServiceInstaller インスタンスインスタンス化ます。最後にServiceProcessInstaller インスタンスおよび ServiceInstaller インスタンスプロジェクト インストーラ クラス追加します

InstallUtil.exe を実行すると、ユーティリティは、RunInstallerAttributetrue設定されているクラスサービス アセンブリで検索ます。プロジェクト インストーラ関連付けられている Installers コレクションクラス追加することにより、サービス アセンブリクラス追加しますRunInstallerAttributefalse場合ユーティリティプロジェクト インストーラ無視します。

ServiceProcessInstallerインスタンスについては、プロパティ変更してログオンしたユーザー以外のアカウントサービス アプリケーション実行するように指定できますサービス実行するときに必要な特定の UsernamePassword組み合わせ指定できますまた、Account使用してコンピュータシステム アカウントローカル サービス アカウントネットワーク サービス アカウント、またはユーザー アカウントサービス実行するように指定できます

メモメモ

コンピュータシステム アカウント管理者アカウントとは異なります

通常コード内の ServiceInstaller ではこのメソッド呼び出しません。このメソッド呼び出すのは、一般的にインストール ユーティリティだけです。インストール ユーティリティは、インストール プロセス中に、ServiceProcessInstaller.Install メソッドと ServiceInstaller.Install メソッド自動的に呼び出します。必要に応じてインストール済みすべてのコンポーネントRollback (または ServiceInstaller.Rollback) を呼び出すことによって、エラー回復します

アプリケーションのインストール ルーチンは、既にインストールされているコンポーネントに関する情報を、プロジェクト インストーラの Installer.Context を使用して自動的に維持します。この状態情報は、ServiceProcessInstaller インスタンスとして継続的に更新されます。ServiceInstaller インスタンスは、ユーティリティインストールされます通常コードではこの状態情報明示的に変更する要はありません。

ServiceProcessInstallerインスタンス化すると、基本クラスコンストラクタ ComponentInstaller が呼び出されます。

使用例使用例

Installer から継承される、MyProjectInstaller という名前のプロジェクト インストーラ作成する例を次に示します。この例では、2 つサービス "Hello-World Service 1" および "Hello-World Service 2" を含んだサービス実行可能ファイルがあることを前提にしています。インストール ユーティリティによって呼び出される MyProjectInstaller のコンストラクタ内では、これらの各サービスに対して ServiceInstaller オブジェクト作成され実行可能ファイルに対して ServiceProcessInstaller作成されます。インストール ユーティリティで MyProjectInstaller を有効なインストーラとして認識できるように、RunInstallerAttribute 属性true設定されます。

インストーラInstallers コレクション追加される前にオプションプロパティプロセス インストーラおよびサービス インストーラ設定されます。インストール ユーティリティが MyProjectInstaller にアクセスすると、InstallerCollection.Add の呼び出し通じて Installers コレクション追加されオブジェクト順番インストールされます。このプロセス中にインストーラは、どのオブジェクトインストールされているのかを示す状態情報保持しますこのためインストール失敗した場合でも、それぞれのオブジェクト順番回復できます

通常プロジェクト インストーラ クラス明示的にインスタンス化しません。プロジェクト インストーラ クラス作成してRunInstallerAttribute追加しますが、実際にクラス呼び出してインスタンス化するのはインストール ユーティリティです。

Imports System
Imports System.Collections
Imports System.Configuration.Install
Imports System.ServiceProcess
Imports System.ComponentModel

<RunInstallerAttribute(True)> _
Public Class MyProjectInstaller
    Inherits Installer
    Private serviceInstaller1 As ServiceInstaller
    Private serviceInstaller2 As ServiceInstaller
    Private processInstaller As ServiceProcessInstaller
    
    
    Public Sub New()
        ' Instantiate installers for process and services.
        processInstaller = New ServiceProcessInstaller()
        serviceInstaller1 = New ServiceInstaller()
        serviceInstaller2 = New ServiceInstaller()
        
        ' The services will run under the system account.
        processInstaller.Account = ServiceAccount.LocalSystem
        
        ' The services will be started manually.
        serviceInstaller1.StartType = ServiceStartMode.Manual
        serviceInstaller2.StartType = ServiceStartMode.Manual
        
        ' ServiceName must equal those on ServiceBase derived classes.
            
        serviceInstaller1.ServiceName = "Hello-World Service 1"
        serviceInstaller2.ServiceName = "Hello-World Service 2"
        
        ' Add installers to collection. Order is not important.
        Installers.Add(serviceInstaller1)
        Installers.Add(serviceInstaller2)
        Installers.Add(processInstaller)
    End Sub
End Class

using System;
using System.Collections;
using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;

[RunInstallerAttribute(true)]
public class MyProjectInstaller: Installer{
   private ServiceInstaller serviceInstaller1;
   private ServiceInstaller serviceInstaller2;
   private ServiceProcessInstaller processInstaller;

   public MyProjectInstaller(){
      // Instantiate installers for process and services.
      processInstaller = new ServiceProcessInstaller();
      serviceInstaller1 = new ServiceInstaller();
      serviceInstaller2 = new ServiceInstaller();

      // The services run under the system account.
      processInstaller.Account = ServiceAccount.LocalSystem;

      // The services are started manually.
      serviceInstaller1.StartType = ServiceStartMode.Manual;
      serviceInstaller2.StartType = ServiceStartMode.Manual;

      // ServiceName must equal those on ServiceBase derived classes.
            
      serviceInstaller1.ServiceName = "Hello-World Service 1";
      serviceInstaller2.ServiceName = "Hello-World Service 2";

      // Add installers to collection. Order is not important.
      Installers.Add(serviceInstaller1);
      Installers.Add(serviceInstaller2);
      Installers.Add(processInstaller);
   }
}

#using <System.dll>
#using <System.ServiceProcess.dll>
#using <System.Configuration.Install.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Configuration::Install;
using namespace System::ServiceProcess;
using namespace System::ComponentModel;

[RunInstallerAttribute(true)]
public ref class MyProjectInstaller: public
 Installer
{
private:
   ServiceInstaller^ serviceInstaller1;
   ServiceInstaller^ serviceInstaller2;
   ServiceProcessInstaller^ processInstaller;

public:
   MyProjectInstaller()
   {
      
      // Instantiate installers for process and services.
      processInstaller = gcnew ServiceProcessInstaller;
      serviceInstaller1 = gcnew ServiceInstaller;
      serviceInstaller2 = gcnew ServiceInstaller;
      
      // The services run under the system account.
      processInstaller->Account = ServiceAccount::LocalSystem;
      
      // The services are started manually.
      serviceInstaller1->StartType = ServiceStartMode::Manual;
      serviceInstaller2->StartType = ServiceStartMode::Manual;
      
      // ServiceName must equal those on ServiceBase derived classes.
            
      serviceInstaller1->ServiceName = "Hello-World Service 1";
      serviceInstaller2->ServiceName = "Hello-World Service 2";
      
      // Add installers to collection. Order is not important.
      Installers->Add( serviceInstaller1 );
      Installers->Add( serviceInstaller2 );
      Installers->Add( processInstaller );
   }

};

import System.*;
import System.Collections.*;
import System.Configuration.Install.*;
import System.ServiceProcess.*;
import System.ComponentModel.*;

/** @attribute RunInstallerAttribute(true)
 */
public class MyProjectInstaller extends Installer
{
    private ServiceInstaller serviceInstaller1;
    private ServiceInstaller serviceInstaller2;
    private ServiceProcessInstaller processInstaller;

    public MyProjectInstaller()
    {
        // Instantiate installers for process and services.
        processInstaller = new ServiceProcessInstaller();
        serviceInstaller1 = new ServiceInstaller();
        serviceInstaller2 = new ServiceInstaller();

        // The services run under the system account.
        processInstaller.set_Account(ServiceAccount.LocalSystem);

        // The services are started manually.
        serviceInstaller1.set_StartType(ServiceStartMode.Manual);
        serviceInstaller2.set_StartType(ServiceStartMode.Manual);

        // ServiceName must equal those on ServiceBase derived classes.
            
        serviceInstaller1.set_ServiceName("Hello-World Service 1");
        serviceInstaller2.set_ServiceName("Hello-World Service 2");

        // Add installers to collection. Order is not important.
        get_Installers().Add(serviceInstaller1);
        get_Installers().Add(serviceInstaller2);
        get_Installers().Add(processInstaller);
    } //MyProjectInstaller
} //MyProjectInstaller
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Configuration.Install.Installer
         System.Configuration.Install.ComponentInstaller
          System.ServiceProcess.ServiceProcessInstaller
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ServiceProcessInstaller メンバ
System.ServiceProcess 名前空間
ServiceInstaller クラス
ServiceBase クラス
ComponentInstaller
Installers
ServiceAccount 列挙
ServiceInstallerDialog



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ServiceProcessInstaller クラス」の関連用語

ServiceProcessInstaller クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ServiceProcessInstaller クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS