I am trying to run a batch file from a network share, but I keep getting the following message: "UNC path are not supported. Defaulting to Windows directory." The batch file is located on \\Server\Soft\WPX5\install.bat
. While logged in as administrator, from my Windows 7 Desktop, I navigate to \\Server\Soft\WP15\
and double click on install.bat, that's when I get the "UNC path are not supported." message. I found some suggestions online stating that mapping drive will not work, but using a symbolic link will solve this issue, but the symbolic link didn't work for me. Below is my batch file content, I would appreciate any assistance that can help me accomplish what I am trying to do. Basically, I want to be able to run the batch file from \\Server\Soft\WP15\install.bat
.
Batch file content
mklink /d %userprofile%\Desktop\WP15 \\server\soft\WP15 \\server\soft\WP15\setup.exe robocopy.exe "\\server\soft\WP15\Custom" /copyall "C:\Program Files (x86)\WP\Custom Templates" Regedit.exe /s \\server\soft\WPX5\Custom\Migrate.reg
Also, how do I remove the symbolic link after the install is completed?
If you open a file with such a path, the program will crash when you try to import a glazing system. You can solve this problem by mapping a normal drive letter to the path that has the UNC path.
In Windows, if you have mapped network drives and you don't know the UNC path for them, you can start a command prompt (Start → Run → cmd.exe) and use the net use command to list your mapped drives and their UNC paths: C:\>net use New connections will be remembered.
A UNC path uses double slashes or backslashes to precede the name of the computer. The path (disk and directories) within the computer are separated with a single slash or backslash, as in the following examples. Note that in the DOS/Windows example, drive letters (c:, d:, etc.) are not used in UNC names.
to get the UNC path you don't need any code. There you should see the shared folders of the computer (share name and location). Just replace the <computername> with the name of your computer with the file.
PUSHD and POPD should help in your case.
@echo off :: Create a temporary drive letter mapped to your UNC root location :: and effectively CD to that location pushd \\server\soft :: Do your work WP15\setup.exe robocopy.exe "WP15\Custom" /copyall "C:\Program Files (x86)\WP\Custom Templates" Regedit.exe /s WPX5\Custom\Migrate.reg :: Remove the temporary drive letter and return to your original location popd
Type PUSHD /?
from the command line for more information.
I feel cls
is the best answer. It hides the UNC message before anyone can see it. I combined it with a @pushd %~dp0
right after so that it would seem like opening the script and map the location in one step, thus preventing further UNC issues.
cls @pushd %~dp0 ::::::::::::::::::: :: your script code here ::::::::::::::::::: @popd
Notes:
pushd
will change your working directory to the scripts location in the new mapped drive.
popd
at the end, to clean up the mapped drive.
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