具有自定义外壳的 Windows 10 Kiosk 模式

具有自定义外壳的 Windows 10 Kiosk 模式

我想要设置一个 Kiosk Modus,用户登录后浏览器会自动启动。

Windows 自定义 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.

$Kiosk_SID = Get-UsernameSID("Kiosk")

# Define actions to take when the shell program exits.

$restart_shell = 0
$restart_device = 1
$shutdown_device = 2

# Set Internet Explorer as the shell for "Cashier", and restart the machine if it's closed.

$ShellLauncherClass.SetCustomShell($Kiosk_SID, "c:\program files\internet explorer\iexplore.exe www.google.com", ($null), ($null), $restart_shell)

# Enable Shell Launcher

$ShellLauncherClass.SetEnabled($TRUE)

当我执行此 powershell 脚本并使用 kiosk 登录时,我只看到黑屏。

答案1

为何这么复杂?

Windows 允许您通过一行注册表或借助组策略来设置自定义用户界面。

政府采购组织(GPO):

User Configuration\Administrative Templates\System\Custom User Interface

您可以在这里设置例如

C:\Program Files\Internet Explorer\iexplore.exe -k www.google.de

这不仅会打开 Internet Explorer 而不是 Explorer 作为用户界面,而且 IE 还将全屏显示(-k 选项)。

注册表:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System

这里需要一个与上面内容相同的 REG_SZ 项。如果“system”键不存在,请创建它。由于这是在“当前用户”配置单元中完成的,因此这只会影响当前登录的用户。

我在一些只能访问一个特定站点的信息亭计算机上使用它,并且它运行良好(我使用域计算机,因此我使用 GPO 方法)。

答案2

GPO 选项在 Windows 10 中仍然存在,至少在企业版和专业版中存在。@Tobias 列出的路径仍然正确。它位于系统主页中,而不是子文件夹中。

本地组策略编辑器

自定义用户界面选项

答案3

这在 Windows 10 中已被称为的功能所取代Shell Launcher,使用它您可以配置 Win32 应用程序来启动而不是 Explorer。

更重要的是,Windows 甚至可以配置为在关闭时自动重新启动应用程序,或者如果应用程序因某种原因被禁止打开,甚至可以重新启动 PC!这是专门为“销售点”/信息亭计算机场景创建的,以确保一种不干预的方法,其中设备将始终只运行一个应用程序。

笔记 这种方法需要Windows 的企业版或教育版 SKU。

要求 Windows 10 企业版或 Windows 10 教育版。

以下是有关该主题的更多信息。 ]

简而言之,您可以使用 PowerShell 来配置您选择的 shell 启动器应用程序,如下所示:

# Check if shell launcher license is enabled
function Check-ShellLauncherLicenseEnabled
{
    [string]$source = @"
using System;
using System.Runtime.InteropServices;

static class CheckShellLauncherLicense
{
    const int S_OK = 0;

    public static bool IsShellLauncherLicenseEnabled()
    {
        int enabled = 0;

        if (NativeMethods.SLGetWindowsInformationDWORD("EmbeddedFeature-ShellLauncher-Enabled", out enabled) != S_OK) {
            enabled = 0;
        }
        return (enabled != 0);
    }

    static class NativeMethods
    {
        [DllImport("Slc.dll")]
        internal static extern int SLGetWindowsInformationDWORD([MarshalAs(UnmanagedType.LPWStr)]string valueName, out int value);
    }

}
"@

    $type = Add-Type -TypeDefinition $source -PassThru

    return $type[0]::IsShellLauncherLicenseEnabled()
}

[bool]$result = $false

$result = Check-ShellLauncherLicenseEnabled
"`nShell Launcher license enabled is set to " + $result
if (-not($result))
{
    "`nThis device doesn't have required license to use Shell Launcher"
    exit
}

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

# Create a handle to the class instance so we can call the static methods.
try {
    $ShellLauncherClass = [wmiclass]"\\$COMPUTER\${NAMESPACE}:WESL_UserSetting"
    } catch [Exception] {
    write-host $_.Exception.Message; 
    write-host "Make sure Shell Launcher feature is enabled"
    exit
    }


# 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. You can change these examples to use the program that you want to use as the shell.

# This example sets the command prompt as the default shell, and restarts the device if the command prompt is 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 Internet Explorer is 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

# Enable Shell Launcher

$ShellLauncherClass.SetEnabled($TRUE)

$IsShellLauncherEnabled = $ShellLauncherClass.IsEnabled()

"`nEnabled is set to " + $IsShellLauncherEnabled.Enabled

# Remove the new custom shells.

$ShellLauncherClass.RemoveCustomShell($Admins_SID)

$ShellLauncherClass.RemoveCustomShell($Cashier_SID)

# Disable Shell Launcher

$ShellLauncherClass.SetEnabled($FALSE)

$IsShellLauncherEnabled = $ShellLauncherClass.IsEnabled()

"`nEnabled is set to " + $IsShellLauncherEnabled.Enabled

相关内容