【问题标题】:%PATH% on Windows 2008 Server actually not workingWindows 2008 Server 上的 %PATH% 实际上不起作用
【发布时间】:2013-05-29 03:31:23
【问题描述】:

如下所示,%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 数据中心
  • 服务包 1
  • 64 位

【问题讨论】:

    标签: path cmd windows-server-2008


    【解决方案1】:

    我认为您不能推迟路径中的变量扩展。路径中的内容按原样使用,在搜索过程中不会重新解释。

    事实上,您必须非常努力才能将其作为%AppData% 输入,因为您需要执行以下操作:

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

    如果你只是使用:

    path=%AppData%\npm;%path%
    

    您会发现实际路径将被替换,因此路径变为:

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

    【讨论】:

      【解决方案2】:

      有趣的是,“关闭再打开”的最后努力实际上奏效了。或者,您可以在添加后复制整个路径并输入 cmd:

      > SET PATH=
      

      并粘贴您的路径。

      【讨论】:

        猜你喜欢
        • 2023-04-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-18
        • 2014-08-20
        • 2012-02-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多