首页 » IT技术 » 正文

修改shift+右键“在此出打开PowerShell窗口”为“在此出打开命令行窗口”

微软一直在推动的Windows PowerShell中的替代命令提示符,windows10 最新的版本,一个这样的变化是Windows PowerShell是Win + X菜单中的默认条目,而不是命令提示符。此外,扩展右键菜单中的“打开命令窗口”也被“打开 PowerShell窗口”替换。虽然这是趋势,但对于普通程序员而言在实际使用过程中,还是原来的命令窗口比较顺手。

当然关于这点网上已经有一堆的修改教程,有靠谱的,有不靠谱的,为了方便操作,我写了一个批处理,能快速的切换shift+右键打开 PowerShell窗口或者cmd窗口,或者使二者共存。

复制下面这个代码保存为.bat或者在点击这里下载现成的文件,使用管理员权限运行即可。

重要!!!!实际使用中发现问题,请注意
实际使用中,发现,注册表项\HKEY_CLASSES_ROOT\Directory\Background\shell\下的子健Powershell和cmd 所有者是:TrustedInstaller 并不是administrators用户组,导致使用管理员权限时依然不能修改注册表。使用以下批处理是,应当先将上述键值的所有者改为administrators用户组。

 

 

 

下载地址:ChangePowerShellToCMD

代码如下

源代码   
@echo off
title 修改shift+右击在此处打开PowerShell
mode con cols=73 lines=20
rem 验证是否是以管理员身份运行
set TempFile_Name=%SystemRoot%\System32\BatTestUACin_SysRt%Random%.batemp
( echo "BAT Test UAC in Temp" >%TempFile_Name% ) 1>nul 2>nul
if not exist %TempFile_Name% (
color 0c
echo.
echo.
echo 错误:没有以管理员身份运行该工具。
echo 该工具将无法使用!
echo.
echo 方法:
echo 找到该工具,右击"以管理员身份运行"。
echo.
echo 按任意键退出该工具..... & pause >nul
exit
)
echo 初始化中,请稍后.....
rem 设置"HKCR\Directory\Background\shell"的所有者为:Everyone
>>fcc_owner.inf echo.[Version]
>>fcc_owner.inf echo.Signature = "$Chicago$"
>>fcc_owner.inf echo.
>>fcc_owner.inf echo.[Registry Keys]
>>fcc_owner.inf echo."CLASSES_ROOT\Directory\Background\shell", 0, "O:WD"
secedit /configure /db fcc_owner.sdb /cfg fcc_owner.inf /log fcc_owner.log
del fcc_owner.*
:main
cls
color 0a
echo *************************************************************************
echo.
echo 该工具用于更改新版windows10系统shift+右键以何种方式打开命令窗口。
echo 系统默认“在此处打开PowerShell”,
echo 此工具可以在“PowerShell”和“CMD”之间切换。
echo.
echo ★注意!请使用管理员权限运行改工具!
echo.
echo 请选择操作:
echo 1、修改为“在此处打开CMD窗口”
echo 2、修改为“在此处打开PowerShell窗口”
echo 3、同时显示1和2
echo.
echo by:frogchou
echo website:frogchou.com
echo *************************************************************************
echo.
set /p var=请输入序号并回车开始修改:
if "%var%"=="1" goto changeCMD
if "%var%"=="2" goto changePowerShell
if "%var%"=="3" (goto changeShowAll) else (goto error)
:changeCMD
reg delete HKCR\Directory\Background\shell\cmd /v HideBasedOnVelocityId /f
reg add HKCR\Directory\Background\shell\cmd /v ShowBasedOnVelocityId /t REG_DWORD /d 6527944 /f
reg delete HKCR\Directory\Background\shell\Powershell /v ShowBasedOnVelocityId /f
reg add HKCR\Directory\Background\shell\Powershell /v HideBasedOnVelocityId /t REG_DWORD /d 6527944 /f
goto end
:changePowerShell
reg delete HKCR\Directory\Background\shell\cmd /v ShowBasedOnVelocityId /f
reg add HKCR\Directory\Background\shell\cmd /v HideBasedOnVelocityId /t REG_DWORD /d 6527944 /f
reg delete HKCR\Directory\Background\shell\Powershell /v HideBasedOnVelocityId /f
reg add HKCR\Directory\Background\shell\Powershell /v ShowBasedOnVelocityId /t REG_DWORD /d 6527944 /f
goto end
:changeShowAll
reg delete HKCR\Directory\Background\shell\cmd /v HideBasedOnVelocityId /f
reg add HKCR\Directory\Background\shell\cmd /v ShowBasedOnVelocityId /t REG_DWORD /d 6527944 /f
reg delete HKCR\Directory\Background\shell\Powershell /v HideBasedOnVelocityId /f
reg add HKCR\Directory\Background\shell\Powershell /v ShowBasedOnVelocityId /t REG_DWORD /d 6527944 /f
goto end
:end
echo.
echo 修改完成!按任意键退出.
pause >nul
exit
:error
echo.
echo 选择错误!按任意键返回主菜单.
pause >nul
goto main

 

 

发表评论