如何使用 Cygwin 的正确路径启动新的 cmd window?

How to launch a new cmd window with the correct path from Cygwin?

当我从开始菜单启动 cmd.exe 时,我在一个新的 window.

中获得注册的(在注册表中)PATH 变量

我想从我的 cygwin+mintty 获得完全相同的效果,并尝试以下操作:

首先我尝试:

bash$  cmd

这给了我一个 cmd shell,就在 mintty 中。但我希望它是全新的 window。 emm...也许我可以试试:

bash$  cmd /c start cmd

它很好地在新的 window 中给了我一个 cmd shell。好的。但是,该命令中的 PATH shell 与新命令不同。

C:\>path
PATH=C:\cygwin64\usr\local\bin;C:\cygwin64\bin;C:\ProgramData\Oracle\Java\javapa
th;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\W
indowsPowerShell\v1.0;C:\opencv\myrelease\bin;C:\Qt.3\mingw482_32\bin;C:\Progr
am Files (x86)\Skype\Phone;C:\Program Files (x86)\Windows Kits.1\Windows Perfo
rmance Toolkit;C:\Program Files\Microsoft SQL Server0\Tools\Binn;C:\cygwin64\
lib\lapack;D:\home\robin_hsu\bin

C:\>

你可以看到那些带cygwin64的路径是不需要的。那么,我该怎么做才能获得一个新的 cmd window,具有正确的路径?

注意:我认为问题是由于 PATH 是可继承的,从 bashcmd

也许有人可以给我一些提示,让我在 cygwin 的 bash 下获得 windows 系统的注册路径。如果可能的话,我可以先将 PATH 更改为所需的路径,然后调用 cmd

所以,这基本上是 Start new cmd.exe and NOT inherit environment? 的重复问题。然而,那个问题并没有要求打开一个新的window,至少对我来说那里的答案没有给我一个正确的路径。下面的命令给出了两者(对我来说,在 XP 上)。

cygstart "$WINDIR\explorer.exe" "$WINDIR\system32\cmd.exe"

唯一的问题是它还会弹出对话框 'File Download - Security Warning' 和 'Windows Explorer - Security Warning'。 This link shows how you can avoid this in general, but I'm not sure if it's possible to remove the warnings for just one specific file. There are also a couple of answers here and here superuser.com 关于禁用警告。

希望对您有所帮助。