UNC Paths not supported in Batch Script

[Closed]
Report
-
Posts
1010
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
-
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.

1 reply

Posts
1010
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
143
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.