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:
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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", 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).
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 /?
You can simply start your script with


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

cd /d "C:\Some Folder"

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

pushd %~dp0

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.
Why not simply add "@CLS " as the first line in the batch file?
That would suppress the message.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.