cmd 问题

1. cmd 显示乱码

1. 临时方案

打开cmd.exe,修改chcp 65001。(GBK=936,UTF8=65001)

2. 永久方案:修改注册表

  1. 进入regedit;
  2. 找到HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe,找到CodePage,修改为65001,否则新建DWORD,重命名为CodePage;
  3. 同理,修改powershell,则在%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe下修改;

2. cmd 查看端口程序

  1. netstat -ano列出所有端口的情况,或者netstat -aon|findstr "8080"查看指定端口
  2. tasklist|findstr "8080"查看占用程序或者打开任务管理器查看
  3. taskkill /f /t /im TNSLSNR.EXE杀掉相应程序或者任务管理器结束进程,或者通过进程号taskkill /pid 14188 /f

3. win10 增加“右键打开CMD”注册表脚本

脚本内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere]
@="Open CMD here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
@="Open CMD here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

[HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHere]
@="Open CMD here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHere\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHere]
@="Open CMD here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHere\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

保存为 OpenCmdHere.reg ,双击接收弹出内容,之后则会修改完成,若使用中文时需要注意字符集