次の方法で共有


InstallContext.Parameters プロパティ

InstallUtil.exe の実行時に入力されたコマンド ライン パラメータを取得します。

Public ReadOnly Property Parameters As StringDictionary
[C#]
public StringDictionary Parameters {get;}
[C++]
public: __property StringDictionary* get_Parameters();
[JScript]
public function get Parameters() : StringDictionary;

プロパティ値

インストール実行可能ファイルの実行時に入力されたコマンド ライン パラメータを表す StringDictionary

解説

新しい InstallContext が作成されるときに、コマンド ライン パラメータを解析した結果が Parameters プロパティに格納されます。パラメータのキーと値は両方とも文字列です。

使用例

[Visual Basic, C#, C++] この例は、 InstallContext クラスの概要で紹介されているクラスの例からの抜粋です。

[Visual Basic, C#, C++] Parameters プロパティを取得して、ユーザーがコマンド ライン引数を入力したかどうかを確認するサンプルを次に示します。このサンプルでは、 LogtoConsole パラメータが設定されているかどうかを確認するために、 IsParameterTrue メソッドも使用します。 yes の場合、これは LogMessage メソッドを使用してステータス メッセージをインストール ログ ファイルとコンソールに書き込みます。

 
Dim myStringDictionary As StringDictionary = myInstallContext.Parameters
If myStringDictionary.Count = 0 Then
   Console.WriteLine("No parameters have been entered in the command line" + _
               "hence, the install will take place in the silent mode")
Else
   ' Check wether the "LogtoConsole" parameter has been set.
   If myInstallContext.IsParameterTrue("LogtoConsole") = True Then
      ' Display the message to the console and add it to the logfile.
      myInstallContext.LogMessage("The 'Install' method has been called")
   End If
End If

[C#] 
StringDictionary myStringDictionary = myInstallContext.Parameters;
if( myStringDictionary.Count == 0 )
{
   Console.WriteLine( "No parameters have been entered in the command line "
      +"hence, the install will take place in the silent mode" );
}
else
{
   // Check whether the "LogtoConsole" parameter has been set.
   if( myInstallContext.IsParameterTrue( "LogtoConsole" ) == true )
   {
      // Display the message to the console and add it to the logfile.
      myInstallContext.LogMessage( "The 'Install' method has been called" );
   }
}

[C++] 
StringDictionary* myStringDictionary = myInstallContext->Parameters;
if (myStringDictionary->Count == 0) {
    Console::Write(S"No parameters have been entered in the command line ");
    Console::WriteLine(S"hence, the install will take place in the silent mode");
} else {
    // Check whether the "LogtoConsole" parameter has been set.
    if (myInstallContext->IsParameterTrue(S"LogtoConsole")) {
        // Display the message to the console and add it to the logfile.
        myInstallContext->LogMessage(S"The 'Install' method has been called");
    }
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

InstallContext クラス | InstallContext メンバ | System.Configuration.Install 名前空間 | StringDictionary