Created
April 5, 2017 04:03
-
-
Save yyoda/ba55c050688bb8cef329e0eebb9c8caa to your computer and use it in GitHub Desktop.
Visual Studio 2017 を管理者モードで起動させるためのスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Visual Studio 2017 を管理者モードで起動させるためのスクリプト | |
#> | |
$path = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" | |
$key_devenv = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" | |
$key_vslauncher = "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe" | |
$value = "RUNASADMIN" | |
$type = "String" | |
### レジストリ追加/更新を行う関数を定義 | |
### reference source http://www.vwnet.jp/Windows/PowerShell/Regedit.htm | |
function RegSet( $RegPath, $RegKey, $RegKeyType, $RegKeyValue ){ | |
# レジストリそのものの有無確認 | |
$Elements = $RegPath -split "\\" | |
$RegPath = "" | |
$FirstLoop = $True | |
foreach ($Element in $Elements ){ | |
if($FirstLoop){ | |
$FirstLoop = $False | |
} | |
else{ | |
$RegPath += "\" | |
} | |
$RegPath += $Element | |
if( -not (test-path $RegPath) ){ | |
echo "Add Registry : $RegPath" | |
md $RegPath | |
} | |
} | |
# Key有無確認 | |
$Result = Get-ItemProperty $RegPath -name $RegKey -ErrorAction SilentlyContinue | |
# キーがあった時 | |
if( $Result -ne $null ){ | |
Set-ItemProperty $RegPath -name $RegKey -Value $RegKeyValue | |
} | |
# キーが無かった時 | |
else{ | |
# キーを追加する | |
New-ItemProperty $RegPath -name $RegKey -PropertyType $RegKeyType -Value $RegKeyValue | |
} | |
Get-ItemProperty $RegPath -name $RegKey | |
} | |
### 実行 | |
RegSet $path $key_devenv $type $value | |
RegSet $path $key_vslauncher $type $value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment