DOS批处理中%cd%和%~dp0的区别
运行命令的目录
echo %cd%
运行文件的目录
echo %~dp0
a.bat
@echo off
echo %cd%
echo %~dp0
C:\Users\macname>.\Desktop\a.bat
C:\Users\macname
C:\Users\macname\Desktop\
C:\Users\macname>cd Desktop
C:\Users\macname\Desktop>a.bat
C:\Users\macname\Desktop
C:\Users\macname\Desktop\
参考:
https://www.cnblogs.com/langtianya/p/5171169.html