UNC Paths not supported in Batch Script

Closed
Riya - 18 May 2015 à 08:09
BrianGreen Posts 1005 Registration date Saturday 17 January 2015 Status Contributor Last seen 30 September 2021 - 19 May 2015 à 07:47
For deletion of older zip logs from an archived location I wrote a batch script:
forfiles -p c:\pathtofiles\ -m *.rar -d -5 -c "cmd /c del @path"
But got an error saying "UNC paths are not supported". What is the way to resolve this issue.
Related:

1 response

BrianGreen Posts 1005 Registration date Saturday 17 January 2015 Status Contributor Last seen 30 September 2021 149
19 May 2015 à 07:47
Hi Riya,

This is taken from https://support.microsoft.com/en-us/help/156276

Obtain the updated Cmd.exe. You must also make a registry entry to be able to use a UNC path as the current directory.

WARNING: Using Registry Editor incorrectly can cause serious, system-wide problems that may require you to reinstall Windows NT to correct them. Microsoft cannot guarantee that any problems resulting from the use of Registry Editor can be solved. Use this tool at your own risk.

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).

WARNING: If you enable this feature and start a Console that has a current directory of an UNC name, start applications from that Console, and then close the Console, it could cause problems in the applications started from that Console.


I hope it helps.