„If you try to set the current directory of a command prompt, you get the error message „CMD does not support UNC paths as current directories.“ What’s going on here?

It’s MS-DOS backwards compatibility.

If the current directory were a UNC, there wouldn’t be anything to return to MS-DOS programs when they call function 19h (Get current drive). That function has no way to return an error code, so you have to return a drive letter. UNCs don’t have a drive letter.

You can work around this behavior by using the pushd command to create a temporary drive letter for the UNC. Instead of passing script.cmd to the CreateProcess function as the lpCommandLine, you can pass cmd.exe /c pushd servershare && script.cmd.“

The Old New Thing : Why cant you set the command prompts current directory to a UNC?

Von admin

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert