WESL_UserSetting

Esta clase configura qué iniciador de Shell de aplicación se inicia en función del identificador de seguridad (SID) del usuario que ha iniciado sesión, y también configura el conjunto de códigos de retorno y las acciones de retorno que el iniciador de Shell realiza cuando se cierra la aplicación.

Sintaxis

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

Miembros

En las tablas siguientes se enumeran todos los métodos y propiedades que pertenecen a esta clase.

Métodos

Métodos Descripción
WESL_UserSetting.SetCustomShell Configura el iniciador de shell para un usuario o grupo específico, en función del SID.
WESL_UserSetting.GetCustomShell Recupera la configuración del iniciador de shell para un usuario o grupo específico, en función del SID.
WESL_UserSetting.RemoveCustomShell Quita una configuración del iniciador de shell para un usuario o grupo específico, en función del SID.
WESL_UserSetting.GetDefaultShell Recupera la configuración predeterminada del iniciador de shell.
WESL_UserSetting.SetDefaultShell Establece la configuración predeterminada del iniciador de shell.
WESL_UserSetting.IsEnabled Recupera un valor que indica si el iniciador de Shell está habilitado o deshabilitado.
WESL_UserSetting.SetEnabled Habilita o deshabilita el iniciador de shell.

Propiedades

Propiedad Tipo de datos Calificadores Descripción
Sid string [lectura, escritura, obligatorio] SID de usuario o grupo.
Cáscara string [lectura, escritura, obligatorio] Aplicación que se va a iniciar como shell.
La propiedad shell puede ser un nombre de archivo en la variable de entorno Path o puede contener una ruta de acceso completa a la aplicación. También puede usar variables de entorno en la ruta de acceso.
Todos los espacios de la propiedad shell deben formar parte de una cadena delimitada por comillas.
CustomReturnCodes Sint32[] [lectura, escritura] Matriz de códigos de retorno personalizados que el shell puede devolver.
CustomReturnCodesAction Sint32[] [lectura, escritura] Matriz de acciones de código de retorno personalizadas que determinan qué acción realiza el iniciador de shell cuando se cierra el shell. Las acciones personalizadas se asignan a la matriz de CustomReturnCodes.
Las posibles acciones son:
0: reinicie el shell.
1 - Reinicie el dispositivo.
2 - Apagar el dispositivo.
3 - No haga nada.
DefaultAction Sint32 [lectura, escritura] La acción predeterminada Shell Launcher se realiza cuando se cierra el shell.
Las posibles acciones se definen como sigue:
0: reinicie el shell.
1 - Reinicie el dispositivo.
2 - Apagar el dispositivo.
3 - No haga nada.

Comentarios

Solo existe una instancia de WESL_UserSetting en un dispositivo con el iniciador de shell.

Shell Launcher usa la configuración personalizada definida para el SID del usuario que ha iniciado sesión actualmente, si existe. De lo contrario, shell Launcher usa una configuración personalizada definida para un SID de grupo del que el usuario es miembro, si existe alguno. Si existen varias configuraciones personalizadas de grupo para el usuario, Shell Launcher usa la primera configuración válida que encuentra. El orden de búsqueda no está definido.

Si no hay ninguna configuración personalizada para el SID del usuario o los SID de grupo de los que el usuario es miembro, shell Launcher usa la configuración predeterminada.

Puede encontrar el SID de un usuario y cualquier grupo del que sea miembro el usuario mediante la herramienta de línea de comandos whoami .

Ejemplo

El siguiente script de Windows PowerShell muestra cómo agregar y quitar configuraciones de shell personalizadas para el iniciador de shell mediante los proveedores de Instrumental de administración de Windows (WMI) para el iniciador de shell.

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

Requisitos

Edición de Windows Compatible
Windows Home No
Windows Pro No
Windows Enterprise
Windows Education
Windows IoT Enterprise