다음을 통해 공유


WEMSAL_UserSetting (Industry 8.1)

7/8/2014

Review the syntax, members, and examples of the WEMSAL_UserSetting WMI provider class for Windows Embedded 8.1 Industry (Industry 8.1).

This Windows Management Instrumentation (WMI) provider class configures the user or group specific settings for Windows 8 Application Launcher.

Syntax

class WEMSAL_UserSetting {
    [read, write, key, Required] string Sid;
    [read, write, Required] string AppUserModelId;
    [read, write]  Sint32 CustomReturnCodes[];
    [read, write]  Sint32 CustomReturnCodesAction[];
    [read, write, Required] sint32 DefaultReturnCodeAction;
};

Members

The following tables list any methods and properties that belong to this class.

Methods

This class contains no methods.

Properties

Property

Data type

Qualifiers

Description

Sid

string

[read, write, key, required]

User or group security identifier (SID) that identifies which account that this configuration is for.

AppUserModelId

string

[read, write, required]

The Application User Model ID (AUMID) of the Windows Store app to launch.

CustomReturnCodes

sint32 []

[read, write]

An array of return codes that the launched app can write to the CustomExitCode local application data setting.

CustomReturnCodesAction

sint32 []

[read, write]

An array of custom return code actions that determine what action Windows 8 Application Launcher takes when the launched app exits. The custom actions map to the array of CustomReturnCodes.

The possible actions are defined in the following table:

ValueDescription
0Restart the application.
1Restart the device.
2Shut down the device.
3Close Windows 8 Application Launcher. This value is not valid if KioskMode is set to true in WEMSAL_Setting.
4Sign out the current user.

DefaultReturnCodeAction

sint32

[read, write, required]

The default action that Windows 8 Application Launcher takes when the launched app exits without writing a CustomExitCode that maps to a corresponding CustomReturnCodesAction.

The possible actions are defined in the following table:

ValueDescription
0Restart the application.
1Restart the device.
2Shut down the device.
3Close Windows 8 Application Launcher. This value is not valid if KioskMode is set to true in WEMSAL_Setting.
4Sign out the current user.

Remarks

You must use an administrator account to change any properties in this class.

The Windows Store app must be installed for the current user in order for Windows 8 Application Launcher to launch the app.

Only Windows Store apps that are specially designed to work with Windows 8 Application Launcher write the CustomExitCode value.

Windows 8 Application Launcher follows the following order to determine the configuration to use.

  1. Current user account configuration. Windows 8 Application Launcher uses the configuration for the current user account, if one exists.

  2. Administrator account. If no specific user configuration exists and the current user account is an administrator account, Windows 8 Application Launcher exits without launching any app.

  3. Group account configuration. If a configuration exists for a group that the current standard (non-administrator) user account is a member of, Windows 8 Application Launcher uses the first matching configuration that it finds.

    Tip

    The group account configuration order is not defined, so we recommend that you avoid assigning a user to multiple groups with different Windows 8 Application Launcher configurations.

  4. Global configuration. If Windows 8 Application Launcher cannot find any configurations defined for the current standard user, Windows 8 Application Launcher uses the global configuration.

You can find the SID for a user and any groups that the user is a member of by using the whoami command-line tool.

For more information about common security identifiers, see Well-known SIDs.

Example

The following Windows PowerShell script demonstrates how to use this class to add or update a user specific configuration for Windows 8 Application Launcher. This example configures Windows 8 Application Launcher to launch Internet Explorer 10 when a specific user (“Cashier” in this example) signs in, and to restart the app when the app exits.

#---Define variables---

$COMPUTER = "localhost"
$NAMESPACE = "root\standardcimv2\embedded"

# Define actions to take when the shell program exits.

$ActionRestartApp = 0
$ActionRestartDevice = 1
$ActionShutdownDevice = 2
$ActionCloseMSAL = 3
$ActionLogoff = 4

# Define a user account to configure. 
# To use a different account, change $UserAccount to a user account that is present on your device.

$UserAccount = "Cashier"

# Define the Windows 8 app to launch, in this example, use the Application Model User ID (AUMID) for Internet Explorer 10.
# To use a different Windows 8 app, change $Win8AppAUMID to the AUMID of the Windows 8 app to launch.

$Win8AppAUMID = "DefaultBrowser_NOPUBLISHERID!Microsoft.InternetExplorer.Default"

# Define the default action for Windows 8 Application Launcher to take when the app exits.

$AppExitAction = $ActionRestartApp

#---Define helper functions---

# Create a function to retrieve the SID for a user account on a machine.
# This function does not check to verify that the user account actually exists.

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 the user account.

$UserSID = Get-UsernameSID($UserAccount)

# Check to see if a configuration already exists for the user, and if so, update it.

$UserConfig = get-WMIObject -namespace $NAMESPACE -computer $COMPUTER -class WEMSAL_UserSetting | 
    where {
        $_.SID -eq $UserSID
    }

if ($UserConfig) {

    # Configuration already exists.  Update it.

    $UserConfig.AppUserModelId = $Win8AppAUMID;
    $Userconfig.DefaultReturnCodeAction = $AppExitAction;
    $UserConfig.Put() | Out-Null;
    
    "Updated user setting for Windows 8 Application Launcher."
    "  SID = " + $UserConfig.Sid
    "  AUMID = " + $UserConfig.AppUserModelId
    "  App exit action = " + $UserConfig.DefaultReturnCodeAction

    } else {

    # Create a new configuration for the user to launch IE10, and log out the user if the app exits.

    Set-WmiInstance -class WEMSAL_UserSetting -ComputerName $COMPUTER -Namespace $NAMESPACE -Argument @{
        Sid = $UserSID;
        AppUserModelId = $Win8AppAUMID;
        DefaultReturnCodeAction = $AppExitAction } | Out-Null;
    
    # Confirm that the settings were created properly.    
    
    $UserConfig = get-WMIObject -namespace $NAMESPACE -computer $COMPUTER -class WEMSAL_UserSetting | 
    where {
        $_.SID -eq $UserSID
    }

    if ($UserConfig) {
        
        "Created new user setting for Windows 8 Application Launcher."
        "  SID = " + $UserConfig.Sid
        "  AUMID = " + $UserConfig.AppUserModelId
        "  App exit action = " + $UserConfig.DefaultReturnCodeAction
    
    } else {
    
        "Could not create user setting for Windows 8 Application Launcher."
    }
}

See Also

Concepts

Windows 8 Application Launcher WMI provider reference
Windows 8 Application Launcher
Guidelines for developing Windows Store apps for Windows Embedded