WESL_UserSetting
このクラスでは、サインインしているユーザーのセキュリティ識別子 (SID) に基づいて起動するアプリケーション シェル起動ツールを構成すると共に、アプリケーションの終了時にシェル起動ツールで実行する一連のリターン コードとリターン アクションを構成します。
構文
class WESL_UserSetting {
[read, write, Required] string Sid;
[read, write, Required] string Shell;
[read, write] Sint32 CustomReturnCodes[];
[read, write] Sint32 CustomReturnCodesAction[];
[read, write] sint32 DefaultAction;
[Static] uint32 SetCustomShell(
[In, Required] string Sid,
[In, Required] string Shell,
[In] sint32 CustomReturnCodes[],
[In] sint32 CustomReturnCodesAction[],
[In] sint32 DefaultAction
);
[Static] uint32 GetCustomShell(
[In, Required] string Sid,
[Out, Required] string Shell,
[Out, Required] sint32 CustomReturnCodes[],
[Out, Required] sint32 CustomReturnCodesAction[],
[Out, Required] sint32 DefaultAction
);
[Static] uint32 RemoveCustomShell(
[In, Required] string Sid
);
[Static] uint32 GetDefaultShell(
[Out, Required] string Shell,
[Out, Required] sint32 DefaultAction
);
[Static] uint32 SetDefaultShell(
[In, Required] string Shell,
[In, Required] sint32 DefaultAction
);
[Static] uint32 IsEnabled(
[Out, Required] boolean Enabled
);
[Static] uint32 SetEnabled(
[In, Required] boolean Enabled);
);
};
メンバー
次の表に、このクラスに属するメソッドとプロパティを示します。
メソッド
メソッド | 説明 |
---|---|
WESL_UserSetting.SetCustomShell | SID に基づいて、特定のユーザーまたはグループに対するシェル起動ツールを構成します。 |
WESL_UserSetting.GetCustomShell | SID に基づいて、特定のユーザーまたはグループに対するシェル起動ツールを取得します。 |
WESL_UserSetting.RemoveCustomShell | SID に基づいて、特定のユーザーまたはグループに対するシェル起動ツールを削除します。 |
WESL_UserSetting.GetDefaultShell | 既定のシェル起動ツールの構成を取得します。 |
WESL_UserSetting.SetDefaultShell | 既定のシェル起動ツールの構成を設定します。 |
WESL_UserSetting.IsEnabled | シェル起動ツールが有効か無効かを示す値を取得します。 |
WESL_UserSetting.SetEnabled | シェルの起動ツールを有効または無効にします。 |
Properties
プロパティ | データ型 | 修飾子 | 説明 |
---|---|---|---|
Sid | string | [read, write, required] | ユーザーまたはグループ SID。 |
シェル | string | [read, write, required] | シェルとして起動するアプリケーション。 シェル プロパティは、Path 環境変数内のファイル名にすることも、アプリケーションへの完全修飾パスを含めることもできます。 パスで環境変数を使用することもできます。 シェル プロパティ内のスペースは、引用符で区切られた文字列の一部である必要があります。 |
CustomReturnCodes | Sint32[] | [read, write] | シェルから返される可能性のあるカスタム リターン コードの配列。 |
CustomReturnCodesAction | Sint32[] | [read, write] | シェルの終了時にシェル起動ツールで実行するアクションを決定するカスタム リターン コード アクションの配列。 カスタム アクションは CustomReturnCodes の配列にマップされます。 可能なアクションは: 0 - シェルを再起動することです。 1 - デバイスを再起動します。 2 - デバイスをシャットダウンします。 3 - 何もしないでください。 |
DefaultAction | Sint32 | [read, write] | シェルランチャーがシェルの終了時に実行する既定のアクション。 可能なアクションは、次のように定義されています: 0 - シェルを再起動します。 1 - デバイスを再起動します。 2 - デバイスをシャットダウンします。 3 - 何もしないでください。 |
注釈
シェル起動ツールを備えたデバイスには、WESL_UserSetting インスタンスが 1 つだけ存在します。
シェル起動ツールでは、現在サインインしているユーザーの SID に対して定義されたカスタム構成が使用されます (存在する場合)。 それ以外の場合、シェル起動ツールでは、ユーザーがメンバーとなっているグループ SID に定義されたカスタム構成が使用されます (存在する場合)。 ユーザーに対して複数のグループ カスタム構成が存在する場合、シェル起動ツールでは、最初に検出された有効な構成が使用されます。 検索順序は定義されていません。
ユーザーの SID またはユーザーがメンバーとなっているグループ SID に対するカスタム構成が存在しない場合、シェル起動ツールでは既定の構成が使用されます。
whoami コマンドライン ツールを使用すれば、ユーザーと、そのユーザーがメンバーになっているグループとに対する SID を見つけることができます。
例
次の Windows PowerShell スクリプトは、シェル起動ツール用の Windows Management Instrumentation (WMI) プロバイダーを使用して、シェル起動ツールに対してカスタム シェル構成を追加および削除する方法を示しています。
$COMPUTER = "localhost"
$NAMESPACE = "root\standardcimv2\embedded"
# Create a handle to the class instance so we can call the static methods.
$ShellLauncherClass = [wmiclass]"\\$COMPUTER\${NAMESPACE}:WESL_UserSetting"
# This well-known security identifier (SID) corresponds to the BUILTIN\Administrators group.
$Admins_SID = "S-1-5-32-544"
# Create a function to retrieve the SID for a user account on a machine.
function Get-UsernameSID($AccountName) {
$NTUserObject = New-Object System.Security.Principal.NTAccount($AccountName)
$NTUserSID = $NTUserObject.Translate([System.Security.Principal.SecurityIdentifier])
return $NTUserSID.Value
}
# Get the SID for a user account named "Cashier". Rename "Cashier" to an existing account on your system to test this script.
$Cashier_SID = Get-UsernameSID("Cashier")
# Define actions to take when the shell program exits.
$restart_shell = 0
$restart_device = 1
$shutdown_device = 2
$do_nothing = 3
# Examples
# Set the command prompt as the default shell, and restart the device if it's closed.
$ShellLauncherClass.SetDefaultShell("cmd.exe", $restart_device)
# Display the default shell to verify that it was added correctly.
$DefaultShellObject = $ShellLauncherClass.GetDefaultShell()
"`nDefault Shell is set to " + $DefaultShellObject.Shell + " and the default action is set to " + $DefaultShellObject.defaultaction
# Set Internet Explorer as the shell for "Cashier", and restart the machine if it's closed.
$ShellLauncherClass.SetCustomShell($Cashier_SID, "c:\program files\internet explorer\iexplore.exe www.microsoft.com", ($null), ($null), $restart_shell)
# Set Explorer as the shell for administrators.
$ShellLauncherClass.SetCustomShell($Admins_SID, "explorer.exe")
# View all the custom shells defined.
"`nCurrent settings for custom shells:"
Get-WmiObject -namespace $NAMESPACE -computer $COMPUTER -class WESL_UserSetting | Select Sid, Shell, DefaultAction
# Remove the new custom shells.
$ShellLauncherClass.RemoveCustomShell($Admins_SID)
$ShellLauncherClass.RemoveCustomShell($Cashier_SID)
要件
Windows エディション | サポートされています |
---|---|
Windows ホーム | いいえ |
Windows Pro | いいえ |
Windows Enterprise | はい |
Windows Education | はい |
Windows IoT Enterprise | はい |