Command Prompt e path UNC

Se da un prompt dei comandi si prova ad esegure il comando: CD \\hostname\Sharename
si ottiene l’errore: CMD non supporta percorsi UNC come directory correnti..

Il motivo è spiegato nel seguente Cmd.exe does not support UNC names as the current directory:

Cmd.exe checks to verify if a UNC name is used for the current directory. It does this because a UNC name may cause problems with child processes launched from such a console when that console is exited or halted. Microsoft Windows NT versions prior to 4.0 did not check this; thus it was possible to use a UNC name as a current directory.

La soluzione sta nell aggiungere un valore DWORD DisableUNCCheck impostato a 1 nella chieve di registro HKEY_CURRENT_USER\Software\Microsoft\Command Processor

Su client XP, Windows Server 2003 e Windows 2000 con i support tools installati è possibile automatizare la creazione della chiave tramite i comando:
REG ADD “HKCU\Software\Microsoft\Command Processor” /V DisableUNCCheck /T REG_DWORD /F /D 1

In alternativa è possibile creare un file DisableUNCCheck.reg con il seguente contenuto:

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
“DisableUNCCheck”=dword:00000001

e quindi usare il comando: regedit /s %LOGONSERVER%\NETLOGON\DisableUNCCheck.reg