I am attempting to change directories to a file server such as:
However, I get the following error:
CMD does not support UNC paths as current directories
What are my options to navigate to that directory?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
If you're considering scripting it, it's always helpful to learn about the
popd commands. Sometimes you can't be sure what drives letters are already used on the machine that the script will run on and you simply need to take the next available drive letter. Since
net use will require you to specify the drive, you can simply use
pushd \\server\folder and then
popd when you're finished.
Or you could switch your shell to PowerShell. It has complete support for UNC paths.
Slightly longer explanation of pushd here: http://shortfastcode.blogspot.com/2010/05/how-to-deal-with-cmd-does-not-support.html
as per @pk use pushd & popd, here is an example.
use pushd to create a temporary virtual drive and after done do a popd to delete the temporary virtual drive
:selectFolder REM Confirm which Folder structure set /p location="Delete files for which QA environment: (P)retoria, (C)ape, (L)uanda or (Q)uit? (C/L/P/Q)" REM I option allows for upper and lower case if /I "%location%"=="C" set folder="\\Tfwcqa\tfwcqa\EORDERS" if /I "%location%"=="L" set folder="\\Tfluaqa\tfluaqa\EORDERS" if /I "%location%"=="P" set folder="\\Tfptaqa\tfptaqa\EORDERS" if /I "%location%"=="Q" goto endBatch REM you can not cd to a network drive so we use pushd to create a temporary virtual drive REM cd /d %folder% pushd %folder% DIR /S REM popd deletes the temporary virtual drive popd
Wouldn't the junction command work here?
pushd \\server_name\folder_name ..EXE path here.. popd
Below code completely worked for me, see the example
@echo off echo "Email payment to prod payment sync program started" pushd \\Server_name\it\0a. IT Projects\XYZ Project\Report Builds\Emailpayment to prod payment sync build "\\Server_name\it\0a. IT Projects\XYZ Project\Report Builds\Emailpayment to prod payment sync build\xyz.exe" popd pushd \\Server_name\it\0a. IT Projects\XYZ Project\Report Builds\Daily Invoice report build "\\Server_name\it\0a. IT Projects\XYZ Project\Report Builds\Daily Invoice report build\XYZ1.exe" %-5 popd echo "Daily invoice report program ended"