%的Windows 2008 Server上的PATH%其实不工作(%PATH% on Window

2019-10-18 04:48发布

正如你可以看到下面, %AppData%\npm是在系统Path变量加入。 我也试着将它添加到用户路径变量。 该文件grunt.cmd存在于目录中,但如果我用一个绝对路径指定它才会起作用。 AKA,路径是行不通的。

C:\Users\TeamCity>echo %path%
%AppData%\npm;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows
\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\10
0\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program F
iles\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Ser
ver\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Ser
ver\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program
Files\nodejs\

C:\Users\TeamCity>dir %appdata%\npm
 Volume in drive C has no label.
 Volume Serial Number is B845-1135

 Directory of C:\Users\TeamCity\AppData\Roaming\npm

05/29/2013  03:14 AM    <DIR>          .
05/29/2013  03:14 AM    <DIR>          ..
05/29/2013  03:14 AM               298 grunt
05/29/2013  03:14 AM               159 grunt.cmd
05/29/2013  03:13 AM    <DIR>          node_modules
               2 File(s)            457 bytes
               3 Dir(s)  23,690,498,048 bytes free

C:\Users\TeamCity>grunt
'grunt' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\TeamCity>%appdata%\npm\grunt
grunt-cli: The grunt command line interface. (v0.1.9)

运行在:

  • 在Windows Server 2008 R2数据中心
  • Service Pack 1的
  • 64位

Answer 1:

我不认为你可以推迟路径变量扩展。 什么是在路径被用作是,它不会在搜索过程中重新演绎。

事实上,你必须很努力得到,在作为%AppData%因为你需要做的是这样的:

path=^%AppData^%\npm;%path%

如果你只使用:

path=%AppData%\npm;%path%

你会发现实际的路径将被取代,使路径变为:

C:\Users\TeamCity\AppData\Roaming\npm;C:\Windows\system32; ...


Answer 2:

有趣的是,“将其关闭并重新打开”的最后的努力,实际工作。 或者,你可以在你加入CMD后,和类型复制整个路径:

> SET PATH=

并粘贴路径。



文章来源: %PATH% on Windows 2008 Server actually not working