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
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With