what could cause PUSHD to fail?

﹥>﹥吖頭↗ 提交于 2019-12-22 04:48:24

问题


I've got a great big script that is entirely reliant on PUSHD. However suddenly when I type pushd \\server1\dir1 I'm getting:

C:\Documents and Settings\userNameHere>pushd \\server1\dir1
' '
CMD does not support UNC paths as current directories.

OK, I'm aware that CMD doesn't support UNC paths. That's why I'm using PUSHD. When I search for this I find lots of posts that say "When you encounter this message about UNC paths, you should use PUSHD!". Well crap, I'm encountering that message and using PUSHD.

I tried using CMD /E:ON because PUSHD is only active when Command Extensions are enabled, apparently. Same result.

I looked to see if somehow I was out of drive letters (since PUSHD starts at Z: and goes backward to find a drive letter). Nope.

I tried starting my cmd at the c:\ dir (cd c:\ then pushd \\server1\dir1).

I confirmed that the drive is there and I have access to it, via Windows Explorer.

And now I'm out of ideas.

Pushd reference: Link


回答1:


OK the answer to this, as far as I can tell, is that if you're at Y: in your mapped drives then pushd won't work. So you need to do net use y: /delete (or some other drive letter) then map your drive using pushd. I had all drive letters mapped, except for Z and A. Maybe Z is reserved? I dunno.

My mistake was checking to see if Z: was available (it wasn't mapped). Apparently if you've mapped everything up to and including Y: then it won't map Z:. No idea why.




回答2:


You need to make sure command extensions are enabled.

The registry keys are:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions

Set to either 0x1 (Enabled) or 0x0 (Disabled). The user specific setting takes precedence over the machine setting.

Also make sure that there are drive letters available for the pushd command. If all drive letters are already mapped and in use then the pushd command will fail in the same way you have detailed.




回答3:


Would not mapping the drive to the letter as usual would do the trick prior to 'pushd'...as in your example

net use E: \\\\server1\\dir1
pushd E:\
....
popd


来源:https://stackoverflow.com/questions/2411305/what-could-cause-pushd-to-fail

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!