1.桌面新建文本文档:新建文档.txt;
2.打开新建文档.txt,输入:
Windows Registry Editor Version 5.00
; 若原先有,先删除原来的
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin]
; 1.right key:Powershell
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
@="Open Powershell"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command]
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -noexit -command Set-Location -literalPath \"%V\""
; 2.right key:Powershell(root)
[HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin]
@="Open Powershell (root)"
[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"
3.保存.txt关闭文档,修改文件名为 CmdAndPowershellAll.reg;注意这里就是修改扩展名为.reg,双击运行,然后桌面空白处右键会看到已经添加成功。
4.在想要运行的.jar的文件夹中的空白处右键,然后点击Open Powershell,打开的地址就直接是jar包文件所在的地址。
输入 java -jar .\ jar包的全名
历史介绍的原文链接:https://blog.csdn.net/weixin_42217154/article/details/85326795,下面是截取的一部分:
随着微软win10系统的流行,更加强大的powershell崭露头角,采用.net架构编写的Powershell性能更加强大,实现的功能也丰富。此时略显老迈的CMD心有力而力不足。而微软也尝试使用各种方法使PowerShell取代目前的CMD。
但是对于我来说,选择命令行工具还是选择cmd。cmd运行时,大概只占用不到1M左右的内存,而powershell占用20M左右,相比而言,cmd有更高的流畅性,启动速度更快。
从Win10Build14971开始,用户已经无法通过按住Shift、右击资源管理器空白处来选择“在此处打开命令提示符”了,但还是有办法将cmd找回来的,这时候就要用到万能的注册表了。