winutil/functions/private/Invoke-WinUtilSnapFlyout.ps1
MyDrift 46f827fe2f
Toggle logic cleanup (#2527)
* enhance toggle logics

- cleanup Invoke-WPFToggle.ps1
- add attributes member to tweaks
- add "eprestart" for restart explorer to attributes.
- removed restart explorer logics from existing toggles.
- add restart explorer logics to Invoke-WPFToggle.ps1 depending on attribute content

* undo attributes
2024-08-28 12:40:56 -05:00

31 lines
1.1 KiB
PowerShell

function Invoke-WinUtilSnapFlyout {
<#
.SYNOPSIS
Disables/Enables Snap Assist Flyout on startup
.PARAMETER Enabled
Indicates whether to enable or disable Snap Assist Flyout on startup
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Snap Assist Flyout On startup"
$value = 1
} else {
Write-Host "Disabling Snap Assist Flyout On startup"
$value = 0
}
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
taskkill.exe /F /IM "explorer.exe"
Set-ItemProperty -Path $Path -Name EnableSnapAssistFlyout -Value $value
Start-Process "explorer.exe"
} catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}