共用方式為


建立殼層啟動器組態檔

若要設定Shell Launcher,您必須建立組態 XML 檔案,並將其套用至您的裝置。 組態檔必須符合 架構,如 殼層啟動器 XML 架構定義中所定義, (XSD)

本文說明如何設定Shell Launcher組態檔,包括實際範例。

讓我們先來看看 XML 檔案的基本結構。 殼層啟動器組態檔包含:

  • 一或多個 profiles。 每個定義 profile
    • 取代標準 Windows 殼層 () Explorer.exe 的應用程式,該應用程式會在使用者登入時執行
    • 應用程式結束時要採取的默認動作,以及應用程式以特定傳回碼結束時所採取的動作
  • 一或多個 configs。 每個都會 config 將用戶帳戶關聯至 profile

注意

如果配置檔未與使用者帳戶相關聯,則不會有任何作用。

以下是Shell Launcher 組態檔的基本範例,其中包含一個配置檔和一個組態:

<?xml version="1.0" encoding="utf-8" ?>
<ShellLauncherConfiguration
  xmlns="http://schemas.microsoft.com/ShellLauncher/2018/Configuration"
  xmlns:V2="http://schemas.microsoft.com/ShellLauncher/2019/Configuration">
  <Profiles>
    <Profile Id="{GUID}">
      <!-- Add configuration here as needed -->
    </Profile>
  </Profiles>
  <Configs>
    <Config>
      <!-- Add configuration here as needed -->
    </Config>
  </Configs>
</ShellLauncherConfiguration>

版本設定

Shell Launcher 組態 XML 已建立版本。 版本是在 XML 根元素中定義,用來判斷要用來驗證 XML 檔案的架構。 此版本也可用來判斷哪些功能可用於設定。 以下是檔案範例中使用的版本、別名和命名空間的表格:

版本 Alias 命名空間
Windows 10 V2 http://schemas.microsoft.com/ShellLauncher/2019/Configuration
Windows 10 預設值 http://schemas.microsoft.com/ShellLauncher/2018/Configuration

若要授權包含版本特定元素和屬性的相容組態 XML,請一律包含附加元件架構的命名空間,並據以命名空間別名來裝飾屬性和元素。 例如,若要設定 kiosk 應用程式以全螢幕執行,請使用下列範例。 請注意與命名空間相關聯http://schemas.microsoft.com/ShellLauncher/2019/Configuration的別名V2,且別名會標記在和 AllAppsFullScreen 內嵌屬性上AppType

<?xml version="1.0" encoding="utf-8" ?>
<ShellLauncherConfiguration
  xmlns="http://schemas.microsoft.com/ShellLauncher/2018/Configuration"
  xmlns:V2="http://schemas.microsoft.com/ShellLauncher/2019/Configuration">
  <Profiles>
    <Profile Id="{GUID}">
      <!-- Add configuration here as needed -->
      <Shell Shell="%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe" V2:AppType="Desktop" V2:AllAppsFullScreen="true">
    </Profile>
  </Profiles>
  <Configs>
    <Config>
      <!-- Add configuration here as needed -->
    </Config>
  </Configs>
</ShellLauncherConfiguration>

您可以在這裡找到 殼層啟動器 XML 架構定義 (XSD)

設定檔

組態檔可以包含一或多個配置檔。 每個設定檔都有唯一識別 Profile Id 元,並選擇性地為 Name。 例如:

<Profiles>
  <Profile Id="{EDB3036B-780D-487D-A375-69369D8A8F78}" Name="Microsoft Learn example">
    <!-- Add configuration here as needed -->
  </Profile>
</Profiles>

提示

Profile Id XML 檔案中必須是唯一的。 您可以使用 PowerShell Cmdlet New-Guid產生 GUID。

您可以定義當 Defaultprofile 沒有其他設定檔與使用者帳戶相關聯時所使用的 。 這可確保使用裝置的每個使用者都使用相同的應用程式。 範例:

<Profiles>
  <DefaultProfile>
    <!-- Add configuration here as needed -->
  </DefaultProfile>
</Profiles>

命令介面

每個配置檔都會定義 專案 Shell ,其中包含要執行之應用程式的詳細數據。 元素 Shell 具有下列屬性:

屬性 描述 詳細資料
Shell 做為 Windows 殼層的應用程式。 - 針對 通用 Windows 平台 (UWP) 應用程式,您必須提供應用程式使用者模型識別碼 (AUMID) 。 瞭解如何 尋找已安裝應用程式的應用程式使用者模型標識碼
- 針對傳統型應用程式,請指定可執行檔的完整路徑,其可包含格式為的 %variableName%系統環境變數。 您也可以指定應用程式可能需要的任何參數。
V2:AppType 定義應用程式的類型。 允許的值為 DesktopUWP
V2:AllAppsFullScreen 布爾值,定義是否在全螢幕中執行所有應用程式。 - 當設定為 True時,Shell Launcher 會以全螢幕方式執行每個應用程式,或最大化傳統型應用程式。
- 設定為 False 或未設定時,只有自定義殼層應用程式會以全螢幕執行;用戶啟動的其他應用程式則會以視窗模式執行。

範例:

<Profile Id="{GUID}">
  <Shell Shell="" V2:AppType="" V2:AllAppsFullScreen="">
    <!-- Add configuration here as needed -->
  </Shell>
</Profile>

在下一個範例中,天氣應用程式會以全屏幕執行。

<?xml version="1.0" encoding="utf-8"?>
<ShellLauncherConfiguration xmlns="http://schemas.microsoft.com/ShellLauncher/2018/Configuration"
xmlns:V2="http://schemas.microsoft.com/ShellLauncher/2019/Configuration">
  <Profiles>
    <DefaultProfile>
      <Shell Shell="Microsoft.BingWeather_8wekyb3d8bbwe!App" V2:AppType="UWP">
        <DefaultAction Action="RestartShell"/>
      </Shell>
    </DefaultProfile>
  </Profiles>
  <Configs/>
</ShellLauncherConfiguration>

在下一個範例中,Microsoft Edge 會以全螢幕執行,並開啟網站。 網站會在閑置 2 分鐘後重載。

<Profile Id="{EDB3036B-780D-487D-A375-69369D8A8F78}">
    <Shell Shell="%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe --kiosk https://www.contoso.com --edge-kiosk-type=fullscreen --kiosk-idle-timeout-minutes=2" V2:AppType="Desktop" V2:AllAppsFullScreen="true">
        <DefaultAction Action="RestartShell"/>
    </Shell>
</Profile>

ReturnCodeActions

殼層啟動器會定義四個動作來處理應用程式結束。 您可以自定義殼層啟動器,並根據不同的結束代碼使用動作。 列舉如下 ReturnCodeActions

  • RestartShell
  • RestartDevice
  • ShutdownDevice
  • DoNothing

這些動作可以當做預設動作使用,或對應至特定的結束代碼。 請參閱 殼層啟動器 ,以瞭解如何搭配Shell Launcher WMI使用結束代碼。

您最多可以指定四個對應至四個結束代碼的自定義動作,以及一個其他所有結束代碼的默認動作。 當應用程式結束時,如果在自定義動作對應中找不到結束代碼,或沒有定義任何預設動作,則不會發生任何事。 基於這個理由,您至少應該定義 DefaultAction

範例:

<Profile Id="{GUID}">
  <Shell Shell="" V2:AppType="" V2:AllAppsFullScreen="">
    <ReturnCodeActions>
      <ReturnCodeAction ReturnCode="0" Action="RestartShell"/>
      <ReturnCodeAction ReturnCode="-1" Action="RestartDevice"/>
      <ReturnCodeAction ReturnCode="255" Action="ShutdownDevice"/>
      <ReturnCodeAction ReturnCode="1" Action="DoNothing"/>
    </ReturnCodeActions>
    <DefaultAction Action="RestartDevice"/>
  </Shell>
</Profile>

Configs

在底下 Configs,定義一或多個用戶帳戶及其與配置檔的關聯。

使用 指定 <Account Name=""/>個別帳戶。

重要

套用 Shell Launcher 設定之前,請確定指定的使用者帳戶可在裝置上使用,否則會失敗。

對於網域和 Microsoft Entra 帳戶,只要裝置已加入或 Microsoft Entra 加入,即可在裝置加入的網域樹系或租使用者中探索帳戶。 針對本機帳戶,在您設定Shell Launcher的帳戶之前,帳戶必須存在。

本機使用者

本機帳戶可以輸入為 devicename\user.\user或只是 user

<Config>
  <Account Name="Learn Example"/>
  <Profile Id="{GUID}"/>
</Config>

Active Directory 使用者

您必須使用 格式 domain\samAccountName來輸入網域帳戶。

<Config>
  <Account Name="contoso\user"/>
  <Profile Id="{GUID}"/>
</Config>

Microsoft Entra 使用者

Microsoft Entra 帳戶必須使用下列格式來指定:AzureAD\{UPN}AzureAD必須依原樣提供,然後遵循UPN) (Microsoft Entra 用戶主體名稱。

<Config>
  <Account Name="azuread\user@contoso.onmicrosoft.com"/>
  <Profile Id="{GUID}"/>
</Config>

當使用者帳戶登入時,會套用相關聯的Shell Launcher 設定檔,並載入配置檔中指定的應用程式。

自動登入帳戶

使用 <AutoLogonAccount>時,Shell Launcher 會建立和管理用戶帳戶,以在裝置重新啟動後自動登入。 帳戶是名為 的 Kiosk本機標準使用者。

範例:

<Configs>
  <Config>
    <!--account managed by Shell Launcher-->
    <AutoLogonAccount/>
    <Profile Id="{GUID}"/>
  </Config>
  <Configs>
    <!--local account-->
    <Account Name="Learn Example"/>
    <Profile ID="{GUID}"/>
  </Configs>
  <Configs>
    <!--Microsoft Entra account-->
    <Account Name="azuread\kiosk@contoso.com"/>
    <Profile ID="{GUID}"/>
  </Configs>
</Configs>

範例

以下是殼層啟動器組態檔的完整範例,其中包含兩個配置檔和三個組態:

<?xml version="1.0" encoding="utf-8"?>
<ShellLauncherConfiguration xmlns="http://schemas.microsoft.com/ShellLauncher/2018/Configuration" xmlns:V2="http://schemas.microsoft.com/ShellLauncher/2019/Configuration">
  <Profiles>
    <DefaultProfile>
      <Shell Shell="%SystemRoot%\explorer.exe" />
    </DefaultProfile>
    <Profile Id="{EDB3036B-780D-487D-A375-69369D8A8F79}" Name="Weather">
      <Shell Shell="Microsoft.BingWeather_8wekyb3d8bbwe!App" V2:AppType="UWP">
        <DefaultAction Action="RestartShell" />
      </Shell>
    </Profile>
    <Profile Id="{EDB3036B-780D-487D-A375-69369D8A8F78}" Name="Edge">
      <Shell Shell="%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe --kiosk https://www.contoso.com --edge-kiosk-type=fullscreen --kiosk-idle-timeout-minutes=2" V2:AppType="Desktop" V2:AllAppsFullScreen="true">
        <ReturnCodeActions>
          <ReturnCodeAction ReturnCode="0" Action="RestartShell" />
          <ReturnCodeAction ReturnCode="-1" Action="RestartDevice" />
          <ReturnCodeAction ReturnCode="255" Action="ShutdownDevice" />
        </ReturnCodeActions>
        <DefaultAction Action="RestartShell" />
      </Shell>
    </Profile>
  </Profiles>
  <Configs>
    <Config>
      <AutoLogonAccount />
      <Profile Id="{EDB3036B-780D-487D-A375-69369D8A8F78}" />
    </Config>
    <Config>
      <Account Name="azuread\kiosk1@contoso.onmicrosoft.com" />
      <Profile Id="{EDB3036B-780D-487D-A375-69369D8A8F79}" />
    </Config>
    <Config>
      <Account Name="azuread\kiosk2@contoso.onmicrosoft.com" />
      <Profile Id="{EDB3036B-780D-487D-A375-69369D8A8F78}" />
    </Config>
  </Configs>
</ShellLauncherConfiguration>