「管理者として xxxxx をここで開く」が複数あります

「管理者として xxxxx をここで開く」が複数あります

Windows のドライブとディレクトリのコンテキスト メニューから、管理者としてコマンド ウィンドウまたは Powershell ウィンドウを開くオプションが必要です。

私は持てますどちらか下記のように特別な「runas」レジストリキーを作成して設定することで、両方コンテキストメニューにリストされ、両方管理者として実行?

[HKEY_CLASSES_ROOT\Drive\shell\runas]
...
[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
...
[HKEY_CLASSES_ROOT\Directory\shell\runas]
...
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
...
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
...
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
...

答え1

次のレジストリ ハックは、Windows 8.1 のディレクトリに対して機能します。

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\runas]
"HasLUAShield"=""
@="CMD here as administrator"

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /S /K pushd \"%V\""
"DelegateExecute"=""

[HKEY_CLASSES_ROOT\Directory\shell\runasPowerShell]
"HasLUAShield"=""
@="PowerShell here as administrator"

[HKEY_CLASSES_ROOT\Directory\shell\runasPowerShell\command]
@="Powershell Start-Process PowerShell -verb runas -ArgumentList '-noexit', 'Push-Location -literalPath ''\"%V\"'''"
"DelegateExecute"=""

下のドライブに類似のキーrunasとサブキーを追加することもできます。runasPowerShell[HKEY_CLASSES_ROOT\Drive\shell]

CMDとPowerShellの両方を昇格した権限で実行する

関連情報