fix(kiosk): re-fetch WESL after enable, robust launcher quoting, intent comments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,9 +19,12 @@ function Log($m){ "$(Get-Date -f s) $m" | Add-Content $log }
|
|||||||
# Elevating launcher: Shell Launcher runs this as the shell; it relaunches the
|
# Elevating launcher: Shell Launcher runs this as the shell; it relaunches the
|
||||||
# Welcome app elevated (silent via the baked UAC auto-approve).
|
# Welcome app elevated (silent via the baked UAC auto-approve).
|
||||||
$launcher='C:\Windows\Setup\Scripts\Start-WelcomeShell.cmd'
|
$launcher='C:\Windows\Setup\Scripts\Start-WelcomeShell.cmd'
|
||||||
|
$welcomeEscaped = $WelcomeExe.Replace("'","''")
|
||||||
@"
|
@"
|
||||||
@echo off
|
@echo off
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '$WelcomeExe' -Verb RunAs"
|
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -LiteralPath '$welcomeEscaped' -Verb RunAs"
|
||||||
|
REM Shell Launcher tracks this CMD process; the Welcome app runs detached above.
|
||||||
|
REM Loop keeps the process alive so Shell Launcher doesn't restart it on idle.
|
||||||
:loop
|
:loop
|
||||||
timeout /t 3600 >nul
|
timeout /t 3600 >nul
|
||||||
goto loop
|
goto loop
|
||||||
@@ -30,8 +33,10 @@ Log "wrote launcher $launcher"
|
|||||||
|
|
||||||
# --- Shell Launcher v2 (WMI bridge) ---
|
# --- Shell Launcher v2 (WMI bridge) ---
|
||||||
$cls='root\standardcimv2\embedded'
|
$cls='root\standardcimv2\embedded'
|
||||||
$wesl=Get-CimInstance -Namespace $cls -ClassName WESL_UserSetting -ErrorAction Stop
|
# Enable Shell Launcher FIRST, then fetch a fresh instance (the pre-enable
|
||||||
|
# snapshot's instance methods can silently no-op on some WESL builds).
|
||||||
Invoke-CimMethod -Namespace $cls -ClassName WESL_UserSetting -MethodName SetEnabled -Arguments @{Enabled=$true} | Out-Null
|
Invoke-CimMethod -Namespace $cls -ClassName WESL_UserSetting -MethodName SetEnabled -Arguments @{Enabled=$true} | Out-Null
|
||||||
|
$wesl=Get-CimInstance -Namespace $cls -ClassName WESL_UserSetting -ErrorAction Stop
|
||||||
# Default shell stays Explorer for everyone else.
|
# Default shell stays Explorer for everyone else.
|
||||||
Invoke-CimMethod -InputObject $wesl -MethodName SetDefaultShell -Arguments @{Shell='explorer.exe';DefaultAction=[uint32]0} | Out-Null
|
Invoke-CimMethod -InputObject $wesl -MethodName SetDefaultShell -Arguments @{Shell='explorer.exe';DefaultAction=[uint32]0} | Out-Null
|
||||||
# sm-bootstrap => the elevating launcher; on exit, restart the shell (action 0).
|
# sm-bootstrap => the elevating launcher; on exit, restart the shell (action 0).
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ public sealed class BootstrapService(IProcessRunner runner) : IBootstrapService
|
|||||||
{
|
{
|
||||||
public async Task RevertKioskAsync(CancellationToken ct = default)
|
public async Task RevertKioskAsync(CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
|
// -EA SilentlyContinue throughout: Shell Launcher revert is best-effort.
|
||||||
|
// If WESL is unavailable the real user still gets Explorer (no custom shell
|
||||||
|
// for their SID). Intentional: don't fail teardown over a missing WMI class.
|
||||||
// Remove sm-bootstrap custom shell entry + disable Shell Launcher's per-user entry.
|
// Remove sm-bootstrap custom shell entry + disable Shell Launcher's per-user entry.
|
||||||
await Ps(
|
await Ps(
|
||||||
"$c='root\\\\standardcimv2\\\\embedded';" +
|
"$c='root\\\\standardcimv2\\\\embedded';" +
|
||||||
|
|||||||
Reference in New Issue
Block a user