Skip to content

Commit 2fcf076

Browse files
committed
create ep refresh function & map tweaks
1 parent bcfbce6 commit 2fcf076

File tree

5 files changed

+38
-15
lines changed

5 files changed

+38
-15
lines changed

config/tweaks.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,9 +2743,7 @@
27432743
Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Personal\" -Value \"$env:userprofile\\Documents\" -Type ExpandString
27442744
Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"{F42EE2D3-909F-4907-8871-4C22FC0BF756}\" -Value \"$env:userprofile\\Documents\" -Type ExpandString
27452745
Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"{0DDD015D-B06C-45D5-8C4C-F59713854639}\" -Value \"$env:userprofile\\Pictures\" -Type ExpandString
2746-
Write-Host \"Restarting explorer\"
2747-
taskkill.exe /F /IM \"explorer.exe\"
2748-
Start-Process \"explorer.exe\"
2746+
Invoke-WinUtilExplorerRefresh
27492747

27502748
Write-Host \"Waiting for explorer to complete loading\"
27512749
Write-Host \"Please Note - The OneDrive folder at $OneDrivePath may still have items in it. You must manually delete it, but all the files should already be copied to the base user folder.\"
@@ -3054,18 +3052,14 @@
30543052
"InvokeScript": [
30553053
"
30563054
New-Item -Path \"HKCU:\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\" -Name \"InprocServer32\" -force -value \"\"
3057-
Write-Host Restarting explorer.exe ...
3058-
$process = Get-Process -Name \"explorer\"
3059-
Stop-Process -InputObject $process
3055+
Invoke-WinUtilExplorerRefresh
30603056
"
30613057
],
30623058
"UndoScript": [
30633059
"
30643060
Remove-Item -Path \"HKCU:\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\" -Recurse -Confirm:$false -Force
30653061
# Restarting Explorer in the Undo Script might not be necessary, as the Registry change without restarting Explorer does work, but just to make sure.
3066-
Write-Host Restarting explorer.exe ...
3067-
$process = Get-Process -Name \"explorer\"
3068-
Stop-Process -InputObject $process
3062+
Invoke-WinUtilExplorerRefresh
30693063
"
30703064
],
30713065
"link": "https://christitustech.github.io/winutil/dev/tweaks/z--Advanced-Tweaks---CAUTION/RightClickMenu"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
function Invoke-WinUtilExplorerRefresh {
2+
<#
3+
.SYNOPSIS
4+
Refreshes the Windows Explorer
5+
#>
6+
7+
Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock {
8+
# Send the WM_SETTINGCHANGE message to all windows
9+
Add-Type -TypeDefinition @"
10+
using System;
11+
using System.Runtime.InteropServices;
12+
public class Win32 {
13+
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
14+
public static extern IntPtr SendMessageTimeout(
15+
IntPtr hWnd,
16+
uint Msg,
17+
IntPtr wParam,
18+
string lParam,
19+
uint fuFlags,
20+
uint uTimeout,
21+
out IntPtr lpdwResult);
22+
}
23+
"@
24+
25+
$HWND_BROADCAST = [IntPtr]0xffff
26+
$WM_SETTINGCHANGE = 0x1A
27+
$SMTO_ABORTIFHUNG = 0x2
28+
$timeout = 100
29+
30+
# Send the broadcast message to all windows
31+
[Win32]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "ImmersiveColorSet", $SMTO_ABORTIFHUNG, $timeout, [ref]([IntPtr]::Zero))
32+
}
33+
}

functions/private/Invoke-WinUtilSnapFlyout.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ function Invoke-WinUtilSnapFlyout {
1414
Write-Host "Disabling Snap Assist Flyout On startup"
1515
$value = 0
1616
}
17-
# taskkill.exe /F /IM "explorer.exe"
1817
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
19-
taskkill.exe /F /IM "explorer.exe"
2018
Set-ItemProperty -Path $Path -Name EnableSnapAssistFlyout -Value $value
21-
Start-Process "explorer.exe"
2219
} catch [System.Security.SecurityException] {
2320
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
2421
} catch [System.Management.Automation.ItemNotFoundException] {

functions/private/Invoke-WinUtilSnapSuggestion.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ function Invoke-WinUtilSnapSuggestion {
1414
Write-Host "Disabling Snap Assist Suggestion On startup"
1515
$value = 0
1616
}
17-
# taskkill.exe /F /IM "explorer.exe"
1817
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
19-
taskkill.exe /F /IM "explorer.exe"
2018
Set-ItemProperty -Path $Path -Name SnapAssist -Value $value
21-
Start-Process "explorer.exe"
2219
} catch [System.Security.SecurityException] {
2320
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
2421
} catch [System.Management.Automation.ItemNotFoundException] {

functions/public/Invoke-WPFToggle.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ function Invoke-WPFToggle {
3434
"WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $(Get-WinUtilToggleStatus WPFToggleTaskbarAlignment)}
3535
"WPFToggleDetailedBSoD" {Invoke-WinUtilDetailedBSoD $(Get-WinUtilToggleStatus WPFToggleDetailedBSoD)}
3636
}
37+
38+
Invoke-WinUtilExplorerRefresh
3739
}

0 commit comments

Comments
 (0)