Files
2026-06-02 03:37:09 -07:00

91 lines
4.6 KiB
PowerShell

# Check PowerShell version for use in path
if ($PSVersionTable.PSVersion.Major -ge 3) {
# Use new variable syntax in PowerShell 3 and above
$currentDir = $PSScriptRoot
}
else {
# Use old variable syntax in Windows PowerShell 3 and below
$currentDir = (Get-Item .).FullName
}
# Import script-helper.ps1
. "$currentDir\..\..\scripts\script-helper.ps1"
# Before doing ANYTHING, check if windwos is activated
if ((Get-WindowsVersionDetails).LicenseStatus -ne "Licensed") {
& ([ScriptBlock]::Create((Invoke-RestMethod https://get.activated.win))) /HWID /HWID-NoEditionChange
}
#### Set cursor theme to Posys Cursor ####
$cursorkey = "HKCU:\Control Panel\Cursors"
$cursorSchemeStr = (Get-ItemProperty "HKCU:\Control Panel\Cursors\Schemes" -ErrorAction SilentlyContinue)."Posy's Cursor"
if ($cursorSchemeStr) {
$cursorscheme = $cursorSchemeStr -split ","
$cursorarray = "Arrow", "Help", "AppStarting", "Wait", "Crosshair", "IBeam", "NWPen", "No", "SizeNS", "SizeWE", "SizeNWSE", "SizeNESW", "SizeAll", "UpArrow", "Hand", "Pin", "Person"
if (-not (Test-Path $cursorkey)) { New-Item -Path $cursorkey -Force | Out-Null }
0..16 | ForEach-Object { Set-ItemProperty $cursorkey $cursorarray[$_] $cursorscheme[$_] }
Set-ItemProperty -Path $cursorkey -Name "(Default)" -Value "Posy's Cursor" -Type String
} else {
Write-Warning "Cursor scheme 'Posy's Cursor' not found in HKCU. Skipping cursor apply."
}
# Set dark mode and enable transparency - ensure the Personalize key exists
$PersonalizeKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"
if (-not (Test-Path $PersonalizeKey)) {
New-Item -Path $PersonalizeKey -Force | Out-Null
}
Set-ItemProperty -Path $PersonalizeKey -Name "AppsUseLightTheme" -Value 0 -Type DWord
Set-ItemProperty -Path $PersonalizeKey -Name "SystemUsesLightTheme" -Value 0 -Type DWord
Set-ItemProperty -Path $PersonalizeKey -Name "EnableTransparency" -Value 1 -Type DWord
Set-ItemProperty -Path $PersonalizeKey -Name "ColorPrevalence" -Value 0 -Type DWord
# Set accent color - ensure the Explorer\Accent key exists
#$AccentKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent"
#if (-not (Test-Path $AccentKey)) {
# New-Item -Path $AccentKey -Force | Out-Null
#}
#Set-ItemProperty -Path $AccentKey -Name "StartColorSet" -Value 2 -Type DWord
#Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent" -Name "AccentColor" -Value 0x000000 -Type DWord
# Set wallpaper
$wallpaperPath = "$windowsDrive\Windows\Web\Wallpaper\Windows\flooded-city.jpg"
$desktopKey = "HKCU:\Control Panel\Desktop"
if (-not (Test-Path $desktopKey)) { New-Item -Path $desktopKey -Force | Out-Null }
Set-ItemProperty -Path $desktopKey -Name "WallPaper" -Value $wallpaperPath -Type String
Set-ItemProperty -Path $desktopKey -Name "TileWallpaper" -Value 0 -Type String
# Lock screen image is set system-wide in first-time-setup.ps1 via PersonalizationCSP (HKLM).
# HKCU Lock Screen keys (LandscapeAssetPath etc.) are Spotlight metadata - they do not set the background.
$explorerAdv = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
if (-not (Test-Path $explorerAdv)) { New-Item -Path $explorerAdv -Force | Out-Null }
# Align taskbar to the left
Set-ItemProperty -Path $explorerAdv -Name "TaskbarAl" -Value 0 -Type DWord
Set-ItemProperty -Path $explorerAdv -Name "LaunchTo" -Value 1 -Type DWord
# Disable widgets and task view
Set-ItemProperty -Path $explorerAdv -Name "TaskbarDa" -Value 0 -Type DWord
Set-ItemProperty -Path $explorerAdv -Name "ShowTaskViewButton" -Value 0 -Type DWord
# Refresh explorer to apply changes
RUNDLL32.EXE USER32.DLL, UpdatePerUserSystemParameters , 1 , True
# Restart Explorer gracefully so taskbar/wallpaper changes take effect without hard-killing the shell
$shell = New-Object -ComObject Shell.Application
$shell.Windows() | Out-Null # ensure COM is ready
Stop-Process -Name explorer -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 800
if (-not (Get-Process -Name explorer -ErrorAction SilentlyContinue)) {
Start-Process explorer.exe
}
#### Install Apps (User) ####
# Install UWP components (appx/msix/appinstaller) that need the user context (provisioned packages for all users and appinstaller for current user)
#Add-AppxPackage -AppInstallerFile "$uiPath\Files.appinstaller"
## Normnal app installations (Win32 apps, traditional installers, etc)
& "$windowsDrive\Windows\OEM\setup\scripts\install-apps-user.ps1"
## Install apps (modern windows apps, such as: store apps, winget, appx, msix, etc [appx/msix/others can be downloaded from url])
& "$windowsDrive\Windows\OEM\scripts\install-win-apps.ps1"