Win10系统右键添加Powershell和命令提示符方法
更新日期:2024-06-07 14:10
来源:互联网
Win10系统中快速打开Powershell控制台的方法
在Win10系统中,我们经常需要使用Powershell控制台进行操作,但是通过SHIFT+右键呼出右键菜单中的选项确实有些麻烦。下面我将分享一种不需要按Shift右键就可以打开Powershell控制台的方法。
首先,我们需要删除原有的一些注册表项,包括`-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere`、`-HKEY_CLASSES_ROOT\Directory\Background\shell\runas`、`-HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin`。
接着,我们可以通过修改注册表来实现快速打开Powershell控制台的功能。具体操作如下:
1. 右键点击空白处,选择“命令行”,即可快速打开命令行窗口。注册表项如下:
```
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
@="在此处打开命令行窗口"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command]
@="cmd.exe /k pushd \"%V\""
```
2. 右键点击空白处,选择“命令行(管理员)”,即可快速以管理员身份打开命令行窗口。注册表项如下:
```
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="在此处打开命令行窗口(管理员)"
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""
```
3. 按住Shift键同时右键点击空白处,选择“Powershell(管理员)”,即可快速以管理员身份打开Powershell控制台。注册表项如下:
```
[HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin]
@="在此处打开Powershell窗口(管理员)"
"Extended"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin\command]
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -windowstyle hidden -Command $stpath=pwd; Start-Process PowerShell -ArgumentList '-NoExit', '-Command Set-Location -literalPath \"%V\"' -verb RunAs"
```
4. 除了以上方法,还可以通过Powershell调用的方式来打开管理员权限的命令行窗口,注册表项如下:
```
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAdmin]
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAdmin]
@="在此处打开命令行窗口(管理员)"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAdmin\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s', '/k', 'pushd', '%V'\""
```
通过以上方法,我们可以更快捷地打开Powershell控制台,提高操作效率。希望这些内容对大家有所帮助。