28 lines
1.2 KiB
PowerShell
28 lines
1.2 KiB
PowerShell
# PATH가 저장된 레지스트리 경로
|
|
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
|
|
|
|
# 현재 PATH 값 가져오기
|
|
$currentPath = (Get-ItemProperty -Path $regPath -Name Path).Path
|
|
|
|
# 제거할 경로 목록
|
|
$pathsToRemove = @(
|
|
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64",
|
|
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\srcsrv"
|
|
)
|
|
|
|
# 기존 PATH에서 제거할 경로 제외
|
|
$newPath = ($currentPath -split ";" | Where-Object { $_ -notin $pathsToRemove }) -join ";"
|
|
|
|
# 시스템 PATH 업데이트
|
|
Set-ItemProperty -Path $regPath -Name Path -Value $newPath
|
|
|
|
# 환경 변수 변경 사항 적용
|
|
$signature = '[DllImport("user32.dll")] public static extern int SendMessageTimeout(int hWnd, int Msg, int wParam, string lParam, int fuFlags, int uTimeout, out int lpdwResult);'
|
|
$SendMessageTimeout = Add-Type -MemberDefinition $signature -Name 'Win32SendMessageTimeout' -Namespace Win32Functions -PassThru
|
|
$HWND_BROADCAST = 0xffff
|
|
$WM_SETTINGCHANGE = 0x001A
|
|
$SMTO_ABORTIFHUNG = 0x0002
|
|
[void]$SendMessageTimeout::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, 0, "Environment", $SMTO_ABORTIFHUNG, 5000, [ref]0)
|
|
|
|
Write-Host "✅ Windows SDK debugger paths have been removed from PATH!"
|