如果我从一个已有的shell中启动一个新的CMD shell,新的shell会继承现有环境。有没有一种方法可以启动一个新的shell,但让它初始化为系统默认值而不是继承现有环境?
B:\>set _test=blooharky
B:\>cmd
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
B:\>set _
_test=blooharky
期望的结果:
B:\>set _test=blooharky
B:\>cmd /env=default
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
B:\>set _
Environment variable _ not defined
[更新] 此问题的解决方法是 start /i cmd
,由 dbenham 在下面的链接中分享。然而,在当前 shell 已经是第二代的情况下,它并不能提供帮助。例如:
d:\>set _
Environment variable _ not defined
d:\>set _test=blooharky
d:\>cmd /k
:: some work done using _test here...
:: ...but after we need a new clean shell:
d:\>start /i cmd
d:\>set _
_test=blooharky
:: uhoh, our shell isn't clean!