Partilhar via


WESL_UserSetting

Esta classe configura o iniciador da Shell da aplicação iniciado com base no identificador de segurança (SID) do utilizador com sessão iniciada e também configura o conjunto de códigos de retorno e devolve ações que o Shell Launcher executa quando a aplicação sai.

Requisitos de edição do Windows

A lista seguinte contém as edições do Windows que suportam o Shell Launcher:

✅ Enterprise/Enterprise LTSC
Educação ✅
Empresa de Internet das Coisas / LTSC Empresa Internet das Coisas ✅

Sintaxe

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);
    );
};

Membros

As tabelas seguintes listam todos os métodos e propriedades que pertencem a esta classe.

Métodos

Métodos Descrição
WESL_UserSetting.SetCustomShell Configura o Shell Launcher para um utilizador ou grupo específico, com base no SID.
WESL_UserSetting.GetCustomShell Obtém a configuração do Shell Launcher para um utilizador ou grupo específico, com base no SID.
WESL_UserSetting.RemoveCustomShell Remove uma configuração do Shell Launcher para um utilizador ou grupo específico, com base no SID.
WESL_UserSetting.GetDefaultShell Obtém a configuração predefinida do Shell Launcher.
WESL_UserSetting.SetDefaultShell Define a configuração predefinida do Iniciador de Shell.
WESL_UserSetting.IsEnabled Obtém um valor que indica se o Iniciador de Shell está ativado ou desativado.
WESL_UserSetting.SetEnabled Ativa ou desativa o Iniciador de Shell.

Propriedades

Propriedade Tipo de dados Qualificadores Descrição
Sid string [leitura, escrita, obrigatório] SID de utilizador ou grupo.
shell string [leitura, escrita, obrigatório] A aplicação a iniciar como shell.
A propriedade shell pode ser um nome de ficheiro na variável de ambiente Caminho ou pode conter um caminho completamente qualificado para a aplicação. Também pode utilizar variáveis de ambiente no caminho.
Todos os espaços na propriedade shell têm de fazer parte de uma cadeia delimitada por aspas.
CustomReturnCodes Sint32[] [ler, escrever] Uma matriz de códigos de retorno personalizados que podem ser devolvidos pela shell.
CustomReturnCodesAction Sint32[] [ler, escrever] Uma matriz de ações de código de retorno personalizadas que determinam a ação que o Shell Launcher executa quando a shell sai. As ações personalizadas mapeiam para a matriz de CustomReturnCodes.
As ações possíveis são:
0 - Reinicie a shell.
1 - Reinicie o dispositivo.
2 - Encerre o dispositivo.
3 - Não faça nada.
DefaultAction Sint32 [ler, escrever] A ação predefinida Do Shell Launcher é executada quando a shell sai.
As ações possíveis são definidas da seguinte forma:
0 - Reinicie a shell.
1 - Reinicie o dispositivo.
2 - Encerre o dispositivo.
3 - Não faça nada.

Comentários

Existe apenas uma instância WESL_UserSetting num dispositivo com o Shell Launcher.

O Shell Launcher utiliza a configuração personalizada definida para o SID do utilizador com sessão iniciada atualmente, se existir. Caso contrário, o Shell Launcher utiliza uma configuração personalizada definida para um SID de grupo do qual o utilizador é membro, se existir alguma. Se existirem várias configurações personalizadas de grupo para o utilizador, o Shell Launcher utiliza a primeira configuração válida que encontrar. A ordem de pesquisa não está definida.

Se não existir nenhuma configuração personalizada para o SID do utilizador ou quaisquer SIDs de grupo dos quais o utilizador seja membro, o Shell Launcher utiliza a configuração predefinida.

Pode encontrar o SID de um utilizador e de quaisquer grupos dos quais o utilizador seja membro através da ferramenta de linha de comandos whoami .

Exemplo

O seguinte script de Windows PowerShell demonstra como adicionar e remover configurações de shell personalizadas para o Shell Launcher através dos fornecedores do Windows Management Instrumentation (WMI) para o Shell Launcher.

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