I'm trying to create a batch script that will open a program in a different environment (so I can make a portable version of it).

I use this set APPDATA=%CD%\data to tell it to do that. The problem I'm facing is that I get the following error when the batch starts:

CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory.

I want to, instead use the cd command to change it to the batch directory. Is there an easy way to do this?

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

If it is on a network drive you might still have issues unless you map the drive buy why not do the following?

APPDATA=%~dp0
cd /d %APPDATA%

By doing a cls you can also clear the error but it the script is run from a UNC path you will receiving this error, you will just have to map it or CLS the error out.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.