11a531003e
Enhance Install-FwsGameboot.ps1 with automatic login and game launch capabilities: - Add -Password parameter for optional auto-login password configuration - Verify prerequisites: local admin account and password requirements - Deploy games.json configuration file alongside scripts - Implement auto-login via Windows registry (AutoAdminLogon settings) - Add scheduled task for auto-launching fws-play at user logon - Tighten file ACLs on deployment directory (SYSTEM/Admins full, Users read-only) - Replace hibernation note with full reboot explanation - Enhance documentation with parameter descriptions and prerequisite validation details - Update user warnings to reflect auto-login kiosk security implications Workflow: boot → auto-login → fws-play launch → game execution → return to FWS.
101 lines
5.9 KiB
PowerShell
101 lines
5.9 KiB
PowerShell
<#
|
|
Install-FwsGameboot.ps1 — installe le composant de RETOUR + LANCEMENT AUTO.
|
|
|
|
A lancer UNE FOIS, EN ADMIN, dans le Windows gaming. Met en place le
|
|
"sans login, jeu lance tout seul" :
|
|
- AUTO-LOGIN du compte gaming (pas d'ecran de mot de passe) ;
|
|
- tache AU LOGON qui lance fws-play (lit le jeton, lance le bon jeu, retour) ;
|
|
- tache ONSTART qui arme le boot suivant vers FWS (filet anti-crash) ;
|
|
- powercfg /h off (reboot PLEIN → NTFS jamais "sale").
|
|
|
|
PREREQUIS VERIFIES par ce script (echec explicite sinon) :
|
|
- le compte courant est ADMINISTRATEUR local (bcdedit + taches SYSTEM) ;
|
|
- le compte n'a PAS de mot de passe, OU -Password est fourni.
|
|
|
|
Empreinte minimale, SANS interference avec Vanguard (aucune injection/hook noyau).
|
|
|
|
Parametres :
|
|
-Password <str> Mot de passe du compte pour l'auto-login. OMETTRE si le
|
|
compte n'a pas de mot de passe. Fourni => stocke EN CLAIR
|
|
dans le registre (limitation AutoAdminLogon) : preferer
|
|
Sysinternals Autologon.exe (secret LSA chiffre).
|
|
#>
|
|
#Requires -RunAsAdministrator
|
|
param([string]$Password)
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
# --- Prereq 1 : le compte gaming DOIT etre admin local (SID, locale-independant) ---
|
|
try {
|
|
$adminGrp = (Get-LocalGroup -SID 'S-1-5-32-544').Name # "Administrators"/"Administrateurs"
|
|
$members = Get-LocalGroupMember -Group $adminGrp -ErrorAction Stop
|
|
$isAdmin = $members | Where-Object { $_.Name -ieq "$Env:COMPUTERNAME\$Env:USERNAME" -or $_.Name -ieq $Env:USERNAME }
|
|
} catch { $isAdmin = $null }
|
|
if (-not $isAdmin) {
|
|
throw "Le compte '$Env:USERNAME' doit etre ADMINISTRATEUR local : fws-play appelle bcdedit et pilote des taches SYSTEM. Ajoute-le au groupe administrateurs puis relance."
|
|
}
|
|
|
|
# --- Prereq 2 : auto-login fiable => compte sans mot de passe OU -Password fourni ---
|
|
$pwdRequired = $true
|
|
try { $pwdRequired = (Get-LocalUser -Name $Env:USERNAME).PasswordRequired } catch { }
|
|
if ($pwdRequired -and -not $PSBoundParameters.ContainsKey('Password')) {
|
|
throw "Le compte '$Env:USERNAME' exige un mot de passe : relance avec -Password '<mdp>', ou retire le mot de passe du compte. Sinon l'auto-login echoue -> ecran de connexion -> la boucle gameboot se bloque."
|
|
}
|
|
|
|
# --- Deploiement des scripts + durcissement ACL (exe potentiellement lance ELEVE) ---
|
|
$dest = Join-Path $Env:ProgramData 'FWS'
|
|
New-Item -ItemType Directory -Force -Path $dest | Out-Null
|
|
foreach ($f in 'fws-return.ps1','fws-play.ps1','games.json') {
|
|
Copy-Item (Join-Path $PSScriptRoot $f) $dest -Force
|
|
}
|
|
# SYSTEM + Administrateurs = plein controle ; Utilisateurs = lecture seule ; heritage retire.
|
|
& icacls $dest /inheritance:r /grant:r 'SYSTEM:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' '*S-1-5-32-545:(OI)(CI)RX' | Out-Null
|
|
|
|
# (1) Reboot PLEIN : pas de Fast Startup → volumes propres.
|
|
& powercfg /h off 2>$null
|
|
|
|
# (2) AUTO-LOGIN du compte courant.
|
|
$winlogon = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
|
|
Set-ItemProperty $winlogon 'AutoAdminLogon' '1' -Force
|
|
Set-ItemProperty $winlogon 'ForceAutoLogon' '1' -Force
|
|
Set-ItemProperty $winlogon 'DefaultUserName' $Env:USERNAME -Force
|
|
Set-ItemProperty $winlogon 'DefaultDomainName' '.' -Force # '.' = local, immune au renommage
|
|
if ($PSBoundParameters.ContainsKey('Password')) {
|
|
Set-ItemProperty $winlogon 'DefaultPassword' $Password -Force
|
|
Write-Warning "Mot de passe stocke EN CLAIR dans le registre. Preferer Sysinternals Autologon.exe (LSA chiffre)."
|
|
} else {
|
|
Remove-ItemProperty $winlogon 'DefaultPassword' -ErrorAction SilentlyContinue
|
|
Write-Host "Auto-login sans mot de passe stocke (compte sans mot de passe verifie)."
|
|
}
|
|
|
|
# (3) Tache AU LOGON : lancer fws-play (lit le jeton, lance le jeu, gere le retour).
|
|
$playAction = New-ScheduledTaskAction -Execute 'powershell.exe' `
|
|
-Argument ('-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "{0}\fws-play.ps1"' -f $dest)
|
|
$playTrigger = New-ScheduledTaskTrigger -AtLogOn -User $Env:USERNAME
|
|
$playPrincipal = New-ScheduledTaskPrincipal -UserId $Env:USERNAME -LogonType Interactive -RunLevel Highest
|
|
$playSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
|
Register-ScheduledTask -TaskName 'FWS-Play-OnLogon' -Action $playAction -Trigger $playTrigger `
|
|
-Principal $playPrincipal -Settings $playSettings -Force | Out-Null
|
|
|
|
# (4) Tache ONSTART (SYSTEM) : armer le boot suivant vers FWS au demarrage.
|
|
# Filet anti-crash : si Windows redemarre seul (WU, plantage) sans fws-play,
|
|
# le boot suivant repart vers FWS. fws-play RE-AFFIRME Windows apres lancement
|
|
# (gere la course avec cette tache — voir fws-play.ps1).
|
|
$retAction = New-ScheduledTaskAction -Execute 'powershell.exe' `
|
|
-Argument ('-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "{0}\fws-return.ps1" -Target FWS' -f $dest)
|
|
$retTrigger = New-ScheduledTaskTrigger -AtStartup
|
|
$retPrincipal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' -LogonType ServiceAccount -RunLevel Highest
|
|
$retSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
|
Register-ScheduledTask -TaskName 'FWS-Return-OnStart' -Action $retAction -Trigger $retTrigger `
|
|
-Principal $retPrincipal -Settings $retSettings -Force | Out-Null
|
|
|
|
Write-Host ""
|
|
Write-Host "Composant FWS installe dans $dest." -ForegroundColor Green
|
|
Write-Host "Auto-login + lancement auto du jeu configures. Flux : boot -> login auto -> jeu." -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "RAPPELS IMPORTANTS :" -ForegroundColor Yellow
|
|
Write-Host " - POSTE KIOSQUE : auto-login + taches non-UAC => acces physique = bureau admin."
|
|
Write-Host " - NE PAS activer BitLocker sans sauvegarder la cle (flip Secure Boot cote FWS"
|
|
Write-Host " change PCR7 -> ecran de recuperation). Verifie : manage-bde -status"
|
|
Write-Host " - Ne desactive pas Secure Boot / TPM / VBS-HVCI : Vanguard les exige."
|
|
Write-Host " - Ajouter des jeux : editer $dest\games.json (id en [a-z0-9_-])."
|