How to run batch file from network share without "UNC path are not supported" message? How to run batch file from network share without "UNC path are not supported" message? windows windows

How to run batch file from network share without "UNC path are not supported" message?


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 locationpushd \\server\soft:: Do your workWP15\setup.exerobocopy.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 locationpopd

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.


There's a registry setting to avoid this security check (use it at your own risks, though):

Under the registry path

   HKEY_CURRENT_USER
     \Software
       \Microsoft
         \Command Processor

add the value DisableUNCCheck REG_DWORD and set the value to 0 x 1 (Hex).

Note:On Windows 10 version 1803, the setting seems to be located under HKLM:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor