How to remove "UNC paths are not supported. Defaulting to windows directory"

I have a DOS batch script test.bat in a network directory. When I executed it, I got the error message:
---
'\\netdir\test'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
---
The result to run this scriptis is not wrong, but the message hsown is annoying. How to remove it?
jl66Asked:
Who is Participating?
 
DuaneMizellCommented:
Why not simply add "@CLS " as the first line in the batch file?
That would suppress the message.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You can only remove it by using a shortcut or .PIF to the batch file, with settings of working dir to something local. If you call the batch file via UNC path, it tries to set the working dir to that UNC path, and this is not supported (or possible).
0
 
jtdebeerCommented:
You may want to use the command
subst <driveletter> <UNC path>
This will give you a driveletter to use instead of UNC path and then you can delete the substitution afterwards.

see  SUBST /?
0
 
oBdACommented:
You can simply start your script with

C:
CLS

you can of course replace "C:" with an existing drive letter of your choice, and or use

cd /d "C:\Some Folder"
CLS

to change into a folder at the same time.
The error message will still appear, but not long enough to be noticed.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The same would be achieved with

pushd %~dp0
cls

However, this will map the UNC path to a drive.

I don't think that solutions are appropriate, as they do not suppress the message. Subst or net use have to be used before the batch is called.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.