Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001
[HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\VisualStudio\9.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001
[HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\VisualStudio\10.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001
基于 SliverNinja 和 Martin Hollingsworth 现有答案的 强力弹变体。这已经在 Win7/x64环境中用 Visual Studio 2015进行了测试。如果 VisualStudio 正在运行,该脚本将要求您关闭它(不会尝试杀死它)。
$vsversion = "14.0" # VS 2015 (optionally 12, 11, 10, 9, etc...)
$disable = 1 # set to 0 to enable the warning message
# not using Get-Process here because powershell instance can be 64 bit and devenv is 32 bit
if (!(get-wmiobject win32_process -filter "name='devenv.exe'")) {
# Create or (force) update the property
New-ItemProperty -Path "HKCU:\Software\Microsoft\VisualStudio\$vsversion\Debugger" -Name DisableAttachSecurityWarning -Value $disable -PropertyType 'DWORD' -Force
Write-Host Done!
}
else {
Write-Error "Please close Visual Studio first!"
}