%PATH%在Windows 2008 Server实际上不工作 [英] %PATH% on Windows 2008 Server actually not working
问题描述
如下所示,在系统Path变量中添加%AppData%\\\
。我也试过将它添加到用户路径变量。文件
pm grunt.cmd
存在于目录中,但只有在我使用绝对路径指定它时才有效。 AKA,路径不工作。
As you can see below, %AppData%\npm
is added in the system Path variable. I've also tried adding it to the User Path variable. The file grunt.cmd
exists in the directory, but only works if I specify it with an absolute path. AKA, path does not work.
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 Datacenter
- Service Pack 1
- 64位
推荐答案
我不认为你可以推迟变量扩展的路径。路径中的是按原样使用的,它在搜索期间不会被重新解释。
I don't think you can defer variable expansion in the path. What's in the path is used as is, it doesn't get re-interpreted during a search.
事实上,你必须努力工作, %AppData%
,因为您需要执行以下操作:
In fact, you must have worked really hard to get that in as %AppData%
since you would need to do something like:
path=^%AppData^%\npm;%path%
如果你只是使用: / p>
If you were to just use:
path=%AppData%\npm;%path%
你会发现实际路径会被替换,所以路径变成:
you'd find the actual path would be substituted, so that the path becomes:
C:\Users\TeamCity\AppData\Roaming\npm;C:\Windows\system32; ...
这篇关于%PATH%在Windows 2008 Server实际上不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!