Skip to content

Commit 3547ea8

Browse files
Update setup.ps1
add dialogue for lacking explorer restart permissions
1 parent 4f1504f commit 3547ea8

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

current/setup.ps1

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ DO {
151151
1 {
152152
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0
153153
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 0
154-
Write-Output "`nDark mode applied, restarting explorer."
155-
Get-Process explorer | Stop-Process
154+
Write-Output "`nDark mode applied, attempting to restart explorer."
155+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
156156
}
157157
2 {
158158
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 1
159159
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 1
160-
Write-Output "`nLight mode applied, restarting explorer."
161-
Get-Process explorer | Stop-Process
160+
Write-Output "`nLight mode applied, attempting to restart explorer."
161+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
162162
}
163163
}
164164
}
@@ -196,8 +196,8 @@ public class Wallpaper
196196
if ($Mtrail -In 0..7) {
197197
# https://www.makeuseof.com/windows-mouse-trail-enable-disable/#enable-or-disable-mouse-pointer-trails-using-the-registry-editor
198198
set-itemProperty 'hkcu:\Control Panel\Mouse' -name MouseTrails -value $Mtrail
199-
Write-Output "Mouse trail set to $Mtrail, restarting explorer"
200-
Get-Process explorer | Stop-Process
199+
Write-Output "Mouse trail set to $Mtrail, attempting to restart explorer"
200+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
201201
}
202202
}
203203
4 { # Cursor style
@@ -507,8 +507,8 @@ public class Wallpaper
507507
if ($LongTimePattern -match "\S") {
508508
Set-ItemProperty -Path "HKCU:\Control Panel\International" -name sTimeFormat -value "$LongTimePattern"
509509
}
510-
Write-Output "Settings applied - restarting explorer"
511-
Get-Process explorer | Stop-Process
510+
Write-Output "Settings applied, attempting to restart explorer"
511+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
512512
}
513513
}
514514
}
@@ -521,11 +521,11 @@ public class Wallpaper
521521
}
522522
1 { # Show long time
523523
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -name "ShowSecondsInSystemClock" -value 1
524-
Get-Process explorer | Stop-Process
524+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
525525
}
526526
2 { # Show short time
527527
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -name "ShowSecondsInSystemClock" -value 0
528-
Get-Process explorer | Stop-Process
528+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
529529
}
530530
}
531531
}
@@ -579,8 +579,8 @@ public class Wallpaper
579579
$Settings = (Get-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3 -Name Settings).Settings
580580
$Settings[12] = $bit
581581
Set-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3 -Name Settings -Value $Settings
582-
Write-Output "`nTaskbar moved, restarting explorer."
583-
Get-Process explorer | Stop-Process
582+
Write-Output "`nTaskbar moved, attempting to restart explorer."
583+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
584584
}
585585
3 { # Pin and unpin items ( https://github.com/Ccmexec/PowerShell/blob/master/Customize%20TaskBar%20and%20Start%20Windows%2011/CustomizeTaskbar.ps1 )
586586
DO {
@@ -696,12 +696,12 @@ public class Wallpaper
696696
} catch {
697697
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_ShowClassicMode" -Value 1
698698
}
699-
Get-Process explorer | Stop-Process
699+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
700700
}
701701
2 { # New taskbar
702702
try {
703703
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_ShowClassicMode" -Value 0
704-
Get-Process explorer | Stop-Process
704+
try {Get-Process explorer | Stop-Process} catch {Write-Output "Explorer restart failed: changes will apply after a restart"}
705705
} catch {
706706
Write-Output "" # No key is the same as one set to 0
707707
}

0 commit comments

Comments
 (0)