폴더 컨텍스트 메뉴에 ‘Open Powershell here to admin’옵션 추가 탐색기에서 고급 Powershell 프롬프트를

프롬프트를 열 폴더의 상황에 맞는 메뉴를 통해 Windows 탐색기에서 고급 Powershell 프롬프트를 직접 여는 방법을 찾고있었습니다.
Windows 10과 지금까지 본 모든 예제를 사용하고 있습니다. 이전 버전의 Windows 용이었습니다. 이전에 Windows 8.1 에서이 작업을 수행했지만 10으로 업데이트하면 중단되었습니다. Windows 10 에서이 작업을 간단히 수행했지만 업데이트가 다시 발생했습니다 (2015 년 12 월).

누구나이 기능을 Windows에 추가 하는 올바른 방법을 알고 있습니까? 아니면 향후 Windows 업데이트로 덮어 쓰게됩니까?



답변

이것이 현재 Windows 탐색기의 상황에 맞는 메뉴에이 기능을 추가하는 유일한 방법입니다.

[승격 된 Powershell 프롬프트에서이 스크립트 실행]

$menu = 'Open Windows PowerShell Here as Administrator'
$command = "$PSHOME\powershell.exe -NoExit -NoProfile -Command ""Set-Location '%V'"""

'directory', 'directory\background', 'drive' | ForEach-Object {
    New-Item -Path "Registry::HKEY_CLASSES_ROOT\$_\shell" -Name runas\command -Force |
    Set-ItemProperty -Name '(default)' -Value $command -PassThru |
    Set-ItemProperty -Path {$_.PSParentPath} -Name '(default)' -Value $menu -PassThru |
    Set-ItemProperty -Name HasLUAShield -Value ''
}

이 스크립트는 다음 링크에서 가져 왔습니다.

http://www.powershellmagazine.com/2013/06/25/pstip-how-to-start-an-elevated-powershell-from-windows-explorer/

99 %는 최신 Windows 패치가 레지스트리 설정을 ‘제거’하기 전에 수행 한 방식이라고 확신합니다 (numlock 부팅 상태와 같은 다른 사용자 정의도 제거했지만 성가신 것은 아닙니다).

더 나은 접근 방식을 알고 있다면 즉, 변동성이 크지 않은 경우 알려 주시면 그 답변을 수락하겠습니다.


답변

나는 이것을 이렇게하고있다. 내가 만든 작은 메뉴의 일부입니다. 원하는대로 편집하십시오.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\OAPS.Tools]
"ImpliedSelectionModel"=dword:00000001
"Icon"="imageres.dll,-5373"
"ExplorerCommandHandler"="{BF0AC53F-D51C-419F-92E3-2298E125F004}"
@="Admin Pshell Here"


답변

다음은 Windows 10에서 폴더의 배경 컨텍스트 메뉴에 CMD와 POWERSHELL을 모두 추가하는 데 사용하는 reg 파일의 사본입니다.

Windows Registry Editor Version 5.00

;Add_Open_CMD_and_Powershell_to_Context_Menu.reg

;Right-Click Background only

;CMD Prompt

[HKEY_CLASSES_ROOT\Directory\Background\shell\01MenuCmd] "MUIVerb"="Command Prompts" "Icon"="cmd.exe" "ExtendedSubCommandsKey"="Directory\Background\ContextMenus\MenuCmd"

[HKEY_CLASSES_ROOT\Directory\Background\shell\01MenuCmd] "MUIVerb"="Command Prompts" "Icon"="cmd.exe" "ExtendedSubCommandsKey"="Directory\Background\ContextMenus\MenuCmd"

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuCmd\shell\open] "MUIVerb"="Command Prompt" "Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuCmd\shell\open\command] @="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuCmd\shell\runas] "MUIVerb"="Command Prompt Elevated" "Icon"="cmd.exe" "HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuCmd\shell\runas\command] @="cmd.exe /s /k pushd \"%V\""

; PowerShell

[HKEY_CLASSES_ROOT\Directory\Background\shell\02MenuPowerShell] "MUIVerb"="PowerShell Prompts" "Icon"="powershell.exe" "ExtendedSubCommandsKey"="Directory\Background\ContextMenus\MenuPowerShell"

[HKEY_CLASSES_ROOT\Directory\Background\shell\02MenuPowerShell] "MUIVerb"="PowerShell Prompts" "Icon"="powershell.exe" "ExtendedSubCommandsKey"="Directory\Background\ContextMenus\MenuPowerShell"

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\open] "MUIVerb"="PowerShell" "Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\open\command] @="powershell.exe -noexit -command Set-Location '%V'"

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas] "MUIVerb"="PowerShell Elevated" "Icon"="powershell.exe" "HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\ContextMenus\MenuPowerShell\shell\runas\command] @="powershell.exe -noexit -command Set-Location '%V'"


답변