次の画面のよう.ps1拡張子のPowerShellスクリプトファイルを実行するため、マウス右クリックのコンテキストメニューの「PowerShellで実行」を利用することがあります。しかし、「管理者として実行」が必要場合、このメニューは利用できません。もっと便利にスクリプトを実行するために、この記事では「PowerShellで実行(管理者)」をコンテキストメニューに追加する方法を紹介します。
1.レジストリを修正してコンテキストメニューに追加
notepadメモ帳を開き、次の内容をregistpowershell.regの名前で格納します。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Runas]
@="PowerShell実行(管理者)"
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Runas\command]
@="powershell.exe \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
0 件のコメント:
コメントを投稿