Skip to content

Commit 32c0df1

Browse files
authored
Merge pull request #1598 from Atlas-OS/fix/new-user-firstlogin-context
Fix new-user first-login tweak context and script prep
2 parents b6da4d5 + 29b3cbe commit 32c0df1

11 files changed

Lines changed: 113 additions & 112 deletions

File tree

src/playbook/Configuration/tweaks/misc/add-newUser-script.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ actions:
66
path: 'HKU\AME_UserHive_Default\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce'
77
value: 'RunScript'
88
data: |
9-
powershell -EP Bypass -NoP & """$([Environment]::GetFolderPath('Windows'))\AtlasModules\Scripts\newUsers.ps1"""
10-
type: REG_SZ
9+
powershell -EP RemoteSigned -NoP & """$([Environment]::GetFolderPath('Windows'))\AtlasModules\Scripts\newUsers.ps1"""
10+
type: REG_SZ

src/playbook/Executables/AtlasDesktop/3. General Configuration/File Sharing/Network Navigation Pane/Disable Network Navigation Pane (default).cmd

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,9 @@ set "settingName=NetworkNavigationPane"
33
set "stateValue=0"
44
set "scriptPath=%~f0"
55

6-
set "___args="%~f0" %*"
7-
fltmc > nul 2>&1 || (
8-
echo Administrator privileges are required.
9-
powershell -c "Start-Process -Verb RunAs -FilePath 'cmd' -ArgumentList """/c $env:___args"""" 2> nul || (
10-
echo You must run this script as admin.
11-
if "%*"=="" pause
12-
exit /b 1
13-
)
14-
exit /b
15-
)
16-
17-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
18-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
6+
set "scriptArgs=%*"
7+
call "%windir%\AtlasModules\Scripts\prepareSetting.cmd" "%settingName%" "%stateValue%" "%scriptPath%" "%scriptArgs%"
8+
if errorlevel 1 exit /b
199

2010

2111
reg add "HKCU\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" /v "System.IsPinnedToNameSpaceTree" /t REG_DWORD /d 0 /f > nul

src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Context Menus/Windows 11/Old Context Menu (default).cmd

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,9 @@ set "settingName=OldContextMenu"
55
set "stateValue=0"
66
set "scriptPath=%~f0"
77

8-
set "___args="%~f0" %*"
9-
fltmc > nul 2>&1 || (
10-
echo Administrator privileges are required.
11-
powershell -c "Start-Process -Verb RunAs -FilePath 'cmd' -ArgumentList """/c $env:___args"""" 2> nul || (
12-
echo You must run this script as admin.
13-
if "%*"=="" pause
14-
exit /b 1
15-
)
16-
exit /b
17-
)
18-
19-
:: Update Registry (State and Path)
20-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
21-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
8+
set "scriptArgs=%*"
9+
call "%windir%\AtlasModules\Scripts\prepareSetting.cmd" "%settingName%" "%stateValue%" "%scriptPath%" "%scriptArgs%"
10+
if errorlevel 1 exit /b
2211

2312
:: End of state and path update
2413

src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/File Explorer Customization/Automatic Folder Discovery/Disable Automatic Folder Discovery (default).cmd

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,18 @@ set "settingName=AutomaticFolderDiscovery"
55
set "stateValue=0"
66
set "scriptPath=%~f0"
77

8-
set "___args="%~f0" %*"
9-
fltmc > nul 2>&1 || (
10-
echo Administrator privileges are required.
11-
powershell -c "Start-Process -Verb RunAs -FilePath 'cmd' -ArgumentList """/c $env:___args"""" 2> nul || (
12-
echo You must run this script as admin.
13-
if "%*"=="" pause
14-
exit /b 1
15-
)
16-
exit /b
17-
)
18-
19-
:: Update Registry (State and Path)
20-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
21-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
8+
set "scriptArgs=%*"
9+
call "%windir%\AtlasModules\Scripts\prepareSetting.cmd" "%settingName%" "%stateValue%" "%scriptPath%" "%scriptArgs%"
10+
if errorlevel 1 exit /b
2211

2312
:: End of state and path update
24-
reg delete "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags" /f
25-
reg add "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell" /v "FolderType" /t REG_SZ /d "NotSpecified" /f
13+
reg delete "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags" /f > nul 2>&1
14+
reg add "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell" /v "FolderType" /t REG_SZ /d "NotSpecified" /f > nul
2615

2716
if "%~1" == "/justcontext" exit /b
2817
if "%~1"=="/silent" exit /b
2918

3019
echo Changes applied successfully.
3120
echo Press any key to exit...
3221
pause > nul
33-
exit /b
22+
exit /b

src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/File Explorer Customization/Gallery/Disable Gallery (default).cmd

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,9 @@ set "settingName=Gallery"
55
set "stateValue=0"
66
set "scriptPath=%~f0"
77

8-
set "___args="%~f0" %*"
9-
fltmc > nul 2>&1 || (
10-
echo Administrator privileges are required.
11-
powershell -c "Start-Process -Verb RunAs -FilePath 'cmd' -ArgumentList """/c $env:___args"""" 2> nul || (
12-
echo You must run this script as admin.
13-
if "%*"=="" pause
14-
exit /b 1
15-
)
16-
exit /b
17-
)
18-
19-
:: Update Registry (State and Path)
20-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
21-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
8+
set "scriptArgs=%*"
9+
call "%windir%\AtlasModules\Scripts\prepareSetting.cmd" "%settingName%" "%stateValue%" "%scriptPath%" "%scriptArgs%"
10+
if errorlevel 1 exit /b
2211

2312
:: End of state and path update
2413

@@ -30,4 +19,4 @@ if "%~1"=="/silent" exit /b
3019
echo Changes applied successfully.
3120
echo Press any key to exit...
3221
pause > nul
33-
exit /b
22+
exit /b

src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Visual Effects (Animations)/Atlas Visual Effects (default).cmd

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,9 @@ set "settingName=Animation"
55
set "stateValue=0"
66
set "scriptPath=%~f0"
77

8-
set "___args="%~f0" %*"
9-
fltmc > nul 2>&1 || (
10-
echo Administrator privileges are required.
11-
powershell -c "Start-Process -Verb RunAs -FilePath 'cmd' -ArgumentList """/c $env:___args"""" 2> nul || (
12-
echo You must run this script as admin.
13-
if "%*"=="" pause
14-
exit /b 1
15-
)
16-
exit /b
17-
)
18-
19-
:: Update Registry (State and Path)
20-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v state /t REG_DWORD /d %stateValue% /f > nul
21-
reg add "HKLM\SOFTWARE\AtlasOS\Services\%settingName%" /v path /t REG_SZ /d "%scriptPath%" /f > nul
8+
set "scriptArgs=%*"
9+
call "%windir%\AtlasModules\Scripts\prepareSetting.cmd" "%settingName%" "%stateValue%" "%scriptPath%" "%scriptArgs%"
10+
if errorlevel 1 exit /b
2211

2312
:: End of state and path update
2413

@@ -40,4 +29,4 @@ if "%~1"=="/silent" exit /b
4029

4130
choice /c:yn /n /m "Finished, would you like to logout to apply the changes? [Y/N] "
4231
if %ERRORLEVEL% == 1 logoff
43-
exit /b
32+
exit /b

src/playbook/Executables/AtlasModules/Scripts/Modules/AllRegistryUsers/AllRegistryUsers.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ function Get-RegUserPaths {
66

77
$regPattern = 'Volatile Environment|AME_UserHive_'
88
if ($NoDefault) {$regPattern = "$regPattern[1-9].*"}
9-
$initPaths = Get-ChildItem -Path "Registry::HKU" | Where-Object { $_.Name -match "S-[0-9-]+(?!.*_)|$regPattern" }
9+
$initPaths = Get-ChildItem -Path "Registry::HKU" -ErrorAction SilentlyContinue | Where-Object { $_.Name -match "S-[0-9-]+(?!.*_)|$regPattern" }
1010

1111
# If the 'Volatile Environment' key exists, that means it is a proper user. Built in accounts/SIDs don't have this key
1212
$paths = @()
1313
if (!$DontCheckEnv) {
1414
foreach ($userKey in $initPaths) {
15-
if ((Get-ChildItem -Path $userKey.PsPath | Where-Object { $_ -match $regPattern }).Count -ne 0) {
15+
if ((Get-ChildItem -Path $userKey.PsPath -ErrorAction SilentlyContinue | Where-Object { $_.Name -match $regPattern }).Count -ne 0) {
1616
$paths += $userKey
1717
}
1818
}
@@ -23,4 +23,4 @@ function Get-RegUserPaths {
2323
return $paths
2424
}
2525

26-
Export-ModuleMember -Function Get-RegUserPaths
26+
Export-ModuleMember -Function Get-RegUserPaths

src/playbook/Executables/AtlasModules/Scripts/RunAsTI.cmd

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ pause > nul
5959
goto RunAsTI-Elevate
6060

6161
:RunAsTI
62-
echo Administrator privileges are required.
62+
set "_runAsTiArgs=%*"
63+
set "RunAsTI_WindowStyle=Normal"
64+
echo %_runAsTiArgs% | findstr /i /c:"/silent" /c:"-silent" /c:"/quiet" > nul 2>&1 && set "RunAsTI_WindowStyle=Hidden"
65+
if /I not "%RunAsTI_WindowStyle%"=="Hidden" echo Administrator privileges are required.
6366

6467
set "0=%~f0"
6568
set "1=%*"
@@ -90,7 +93,7 @@ function RunAsTI ($cmd,$arg) { $id='RunAsTI'; $key="Registry::HKU\$(((whoami /us
9093
function M ($1,$2,$3) {$M."G`etMethod"($1,[type[]]$2).invoke(0,$3)}; $H=@(); $Z,(4*$Z+16)|% {$H += M "AllocHG`lobal" $I $_}
9194
M "WriteInt`Ptr" ($P,$P) ($H[0],$As.Handle); $A1.f1=131072; $A1.f2=$Z; $A1.f3=$H[0]; $A2.f1=1; $A2.f2=1; $A2.f3=1; $A2.f4=1
9295
$A2.f6=$A1; $A3.f1=10*$Z+32; $A4.f1=$A3; $A4.f2=$H[1]; M "StructureTo`Ptr" ($D[2],$P,[boolean]) (($A2 -as $D[2]),$A4.f2,$false)
93-
$Run=@($null, "powershell -win 1 -nop -c iex `$env:R; # $id", 0, 0, 0, 0x0E080600, 0, $null, ($A4 -as $T[4]), ($A5 -as $T[5]))
96+
$Run=@($null, "powershell -windowstyle $env:RunAsTI_WindowStyle -nop -c iex `$env:R; # $id", 0, 0, 0, 0x0E080600, 0, $null, ($A4 -as $T[4]), ($A5 -as $T[5]))
9497
F 'CreateProcess' $Run; return}; $env:R=''; rp $key $id -force; $priv=[diagnostics.process]."GetM`ember"('SetPrivilege',42)[0]
9598
'SeSecurityPrivilege','SeTakeOwnershipPrivilege','SeBackupPrivilege','SeRestorePrivilege' |% {$priv.Invoke($null, @("$_",2))}
9699
$HKU=[uintptr][uint32]2147483651; $NT='S-1-5-18'; $reg=($HKU,$NT,8,2,($HKU -as $D[9])); F 'RegOpenKeyEx' $reg; $LNK=$reg[4]
@@ -104,7 +107,7 @@ function RunAsTI ($cmd,$arg) { $id='RunAsTI'; $key="Registry::HKU\$(((whoami /us
104107
if ($11bug) {$w=0; do {if($w-gt40){break}; sleep -mi 250;$w++} until (Q); [Microsoft.VisualBasic.Interaction]::AppActivate($(Q))}
105108
if ($11bug) {[Windows.Forms.SendKeys]::SendWait($path)}; do {sleep 7} while(Q); L '.Default' $LNK 'Interactive User'
106109
'@; $V='';'cmd','arg','id','key'|%{$V+="`n`$$_='$($(gv $_ -val)-replace"'","''")';"}; sp $key $id $($V,$code) -type 7 -force -ea 0
107-
start powershell -args "-win 1 -nop -c `n$V `$env:R=(gi `$key -ea 0).getvalue(`$id)-join''; iex `$env:R" -verb runas
110+
start powershell -args "-windowstyle $env:RunAsTI_WindowStyle -nop -c `n$V `$env:R=(gi `$key -ea 0).getvalue(`$id)-join''; iex `$env:R" -verb runas
108111
} #:RunAsTI lean & mean snippet by AveYo, 2023.07.06
109112

110113
Try {

src/playbook/Executables/AtlasModules/Scripts/newUsers.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
1212
exit /b
1313
)
1414

15-
powershell -ExecutionPolicy Bypass -NoProfile -File "%script%"
15+
powershell -ExecutionPolicy RemoteSigned -NoProfile -File "%script%"
1616

17-
pause
17+
pause
Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
2-
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
3-
}
4-
51
$windir = [Environment]::GetFolderPath('Windows')
62
& "$windir\AtlasModules\initPowerShell.ps1"
73
$atlasDesktop = "$windir\AtlasDesktop"
@@ -20,37 +16,63 @@ Write-Host $title -ForegroundColor Yellow
2016
Write-Host $('-' * ($title.length + 3)) -ForegroundColor Yellow
2117
Write-Host "You'll be logged out in 10 to 20 seconds, and once you login again, your new account will be ready for use."
2218

23-
# Disable Windows 11 context menu & 'Gallery' in File Explorer
24-
if ([System.Environment]::OSVersion.Version.Build -ge 22000) {
25-
& "$atlasDesktop\4. Interface Tweaks\Context Menus\Windows 11\Old Context Menu (default).cmd" /silent
26-
& "$atlasDesktop\4. Interface Tweaks\File Explorer Customization\Gallery\Disable Gallery (default).cmd" /silent
19+
$env:ATLAS_USER_CONTEXT = "1"
20+
try {
21+
# Disable Windows 11 context menu & 'Gallery' in File Explorer
22+
if ([System.Environment]::OSVersion.Version.Build -ge 22000) {
23+
& "$atlasDesktop\4. Interface Tweaks\Context Menus\Windows 11\Old Context Menu (default).cmd" /silent
24+
& "$atlasDesktop\4. Interface Tweaks\File Explorer Customization\Gallery\Disable Gallery (default).cmd" /silent
2725

28-
# Set ThemeMRU (recent themes)
29-
Set-Theme -Path "$([Environment]::GetFolderPath('Windows'))\Resources\Themes\atlas-v0.5.x-dark.theme"
30-
Set-ThemeMRU | Out-Null
31-
}
26+
# Set ThemeMRU (recent themes)
27+
Set-Theme -Path "$([Environment]::GetFolderPath('Windows'))\Resources\Themes\atlas-v0.5.x-dark.theme"
28+
Set-ThemeMRU | Out-Null
29+
}
30+
31+
# Set lockscreen wallpaper
32+
try {
33+
Set-LockscreenImage
34+
}
35+
catch {
36+
Write-Warning "Failed to set lockscreen image: $($_.Exception.Message)"
37+
}
38+
39+
# Disable 'Network' in navigation pane
40+
& "$atlasDesktop\3. General Configuration\File Sharing\Network Navigation Pane\Disable Network Navigation Pane (default).cmd" /silent
41+
42+
# Disable Automatic Folder Discovery
43+
& "$atlasDesktop\4. Interface Tweaks\File Explorer Customization\Automatic Folder Discovery\Disable Automatic Folder Discovery (default).cmd" /silent
3244

33-
# Set lockscreen wallpaper
34-
Set-LockscreenImage
45+
# Set visual effects
46+
& "$atlasDesktop\4. Interface Tweaks\Visual Effects (Animations)\Atlas Visual Effects (default).cmd" /silent
47+
}
48+
finally {
49+
Remove-Item "Env:\ATLAS_USER_CONTEXT" -ErrorAction SilentlyContinue
50+
}
3551

36-
# Disable 'Network' in navigation pane
37-
& "$atlasDesktop\3. General Configuration\File Sharing\Network Navigation Pane\Disable Network Navigation Pane (default).cmd" /silent
52+
# Set taskbar pins
53+
$browser = $null
54+
$setupOptionsPath = "HKLM:\SOFTWARE\AtlasOS\SetupOptions"
55+
$allowedBrowsers = @("Brave", "Firefox", "LibreWolf", "Google Chrome", "Microsoft Edge")
3856

39-
# Disable Automatic Folder Discovery
40-
& "$atlasDesktop\4. Interface Tweaks\File Explorer Customization\Automatic Folder Discovery\Disable Automatic Folder Discovery (default).cmd" /silent
57+
try {
58+
$browser = Get-ItemPropertyValue -Path $setupOptionsPath -Name "Browser" -ErrorAction Stop
59+
}
60+
catch {
61+
Write-Warning "Couldn't read browser selection from '$setupOptionsPath'. Falling back to default taskbar pins."
62+
}
4163

42-
# Set visual effects
43-
& "$atlasDesktop\4. Interface Tweaks\Visual Effects (Animations)\Atlas Visual Effects (default).cmd" /silent
64+
if (![string]::IsNullOrWhiteSpace($browser) -and $browser -notin $allowedBrowsers) {
65+
Write-Warning "Invalid browser value '$browser' found in '$setupOptionsPath'. Falling back to default taskbar pins."
66+
$browser = $null
67+
}
4468

45-
# Set taskbar pins
46-
$valueName = "Browser"
47-
$value = Get-ItemProperty -Path "HKLM:\SOFTWARE\AtlasOS\SetupOptions" -Name $valueName -ErrorAction Stop
48-
$Browser = $value.$valueName
49-
$Browser
69+
if ([string]::IsNullOrWhiteSpace($browser)) {
70+
$browser = $null
71+
}
5072

51-
& "$atlasModules\Scripts\taskbarPins.ps1" $Browser
52-
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Value 1
73+
& "$atlasModules\Scripts\taskbarPins.ps1" $browser
74+
& reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d 1 /f *> $null
5375

5476
# Leave
5577
Start-Sleep 5
56-
logoff
78+
logoff

0 commit comments

Comments
 (0)