添加cmd和powershell到右键菜单的一键脚本
如默
撰写于 2019年 11月 16 日

说明

为了方便起见,将cmd或powershell添加到右键菜单,管理员和非管理员权限,特记录于此。

脚本

此处记录脚本内容,注意分号;之后的内容是注释

cmd(非管理员)

Windows Registry Editor Version 5.00

; 添加到桌面右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here]

@="在此处打开命令行"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here\command]

@="\"C:\\Windows\\System32\\cmd.exe\""

; 添加到文件夹右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_here]

@="在此处打开命令行"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_here\command]

@="\"C:\\Windows\\System32\\cmd.exe\""

Windows PowerShell(非管理员)

Windows Registry Editor Version 5.00

; 添加到桌面右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell_here]

@="在此处打开PowerShell"
"Icon"="powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell_here\command]

@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\""

; 添加到文件夹右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell_here]

@="在此处打开PowerShell"
"Icon"="powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell_here\command]

@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\""

cmd(管理员)

Windows Registry Editor Version 5.00

; 添加到桌面右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_admin_here]

@="在此处打开命令行(管理员)"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_admin_here\command]

@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

; 添加到文件夹右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_admin_here]

@="在此处打开命令行(管理员)"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_admin_here\command]

@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

Windows PowerShell(管理员)

Windows Registry Editor Version 5.00

; 添加到桌面右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell_admin_here]

@="在此处打开PowerShell(管理员)"
"Icon"="powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell_admin_here\command]

@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" Start-Process PowerShell -verb RunAs"

; 添加到文件夹右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell_admin_here]

@="在此处打开PowerShell(管理员)"
"Icon"="powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell_admin_here\command]

@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" Start-Process PowerShell -verb RunAs"

步骤

  1. 复制脚本到记事本或notepad++等编辑器上
  2. 保存为.reg格式的注册表文件
  3. 运行刚刚保存好的注册表文件,提示确定添加时,点击是

OK,大功告成

管理员身份运行时,会先弹出一个powershell框,然后再弹出授权,授权之后才会出现管理员身份的powershell。暂时没有找到可与去除第一个弹框的办法。

此方式添加完毕后,如果在桌面回收站右键显示在此处打开命令行,请打开注册表编辑器,删除此位置计算机\HKEY_CLASSES_ROOT\Folder\shell下的cmd_herepowershell_here文件夹即可

添加cmd和powershell到右键菜单的一键脚本

温馨提示:

本文最后更新于2019年11月16日,已超过1620天没有更新,若内容或图片失效,请留言反馈。

说明

为了方便起见,将cmd或powershell添加到右键菜单,管理员和非管理员权限,特记录于此。

脚本

此处记录脚本内容,注意分号;之后的内容是注释

cmd(非管理员)

Windows Registry Editor Version 5.00

; 添加到桌面右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here]

@="在此处打开命令行"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here\command]

@="\"C:\\Windows\\System32\\cmd.exe\""

; 添加到文件夹右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_here]

@="在此处打开命令行"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_here\command]

@="\"C:\\Windows\\System32\\cmd.exe\""

Windows PowerShell(非管理员)

Windows Registry Editor Version 5.00

; 添加到桌面右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell_here]

@="在此处打开PowerShell"
"Icon"="powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell_here\command]

@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\""

; 添加到文件夹右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell_here]

@="在此处打开PowerShell"
"Icon"="powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell_here\command]

@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\""

cmd(管理员)

Windows Registry Editor Version 5.00

; 添加到桌面右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_admin_here]

@="在此处打开命令行(管理员)"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_admin_here\command]

@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

; 添加到文件夹右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_admin_here]

@="在此处打开命令行(管理员)"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_admin_here\command]

@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

Windows PowerShell(管理员)

Windows Registry Editor Version 5.00

; 添加到桌面右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell_admin_here]

@="在此处打开PowerShell(管理员)"
"Icon"="powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\powershell_admin_here\command]

@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" Start-Process PowerShell -verb RunAs"

; 添加到文件夹右键菜单

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell_admin_here]

@="在此处打开PowerShell(管理员)"
"Icon"="powershell.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\powershell_admin_here\command]

@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" Start-Process PowerShell -verb RunAs"

步骤

  1. 复制脚本到记事本或notepad++等编辑器上
  2. 保存为.reg格式的注册表文件
  3. 运行刚刚保存好的注册表文件,提示确定添加时,点击是

OK,大功告成

管理员身份运行时,会先弹出一个powershell框,然后再弹出授权,授权之后才会出现管理员身份的powershell。暂时没有找到可与去除第一个弹框的办法。

此方式添加完毕后,如果在桌面回收站右键显示在此处打开命令行,请打开注册表编辑器,删除此位置计算机\HKEY_CLASSES_ROOT\Folder\shell下的cmd_herepowershell_here文件夹即可


赞 (0)

猜您想看

  • typecho原生微信小程序

    一直想把网站做成小程序,github上typecho的小程序也都是远古版本,今年官方也升级到了typecho 1.2.1版本,目前还没有可用的小程序,我自己抽空写了一个,开源给大家使用。

    2023年07月18日
  • 联合创新MiniLED显示器M2U一周体验

    最近买的AOC显示器出问题了,返厂检修,临时买了一个联合创新的显示器,体验一下。

    2023年02月09日
  • 迁移Git项目

    之前使用的是GitHub和Gitee,国外的访问速度太慢,国内的又各种限制,所以自己搭建了一个Gitea,用来存放代码,之前的仓库不想丢失log记录等信息,所以需要迁移,特此记录。

    2022年11月29日
  • Nikon Z5 24-70 F4 S 套机入手体验

    最近看到尼康Z5降价了,正好之前的7200D也用了五年,想换个全画幅了,购入体验一下。

    2021年09月10日
  • 同步更新Gitee和GitHub仓库代码

    学校的网络不好,GitHub有时就上不去了,所以需要同步更新Gitee和GitHub两个仓库的代码,做个备份。

    2019年07月23日
  • Microsoft Edge Chromium版使用体验

    早前,微软发布了基于Chromium内核的新版edge浏览器,使用三个月来,体验良好,特记录如下。

    2019年12月11日

评论区(暂无评论)

这里空空如也,快来评论吧~

我要评论

Vaptcha 初始化中...