2011年4月13日星期三
Windows脚本 - %~dp0的含义
有windows角本如下:
@echo off
set PYTHONOPTIMIZE=x
echo "%~p0..\local\py25.exe"
echo "%~d0..\local\py25.exe"
echo "%~0..\local\py25.exe"
echo "%0..\local\py25.exe"
echo "%~dp0..\local\py25.exe"
"%~dp0..\local\py25.exe" uploader.py || pause
@echo on
查看输出:
"\Users\Woody\Downloads\phus-goagent-b17eb51\server\..\local\py25.exe"//缺少盘符"c:"
"C:..\local\py25.exe" //缺少路径"\Users\Woody\Downloads\phus-goagent-b17eb51\server\"
"C:\Users\Woody\Downloads\phus-goagent-b17eb51\server\uploader.bat..\local\py25.exe" //命令本身
""C:\Users\Woody\Downloads\phus-goagent-b17eb51\server\uploader.bat"..\local\py25.exe" //命令本身
"C:\Users\Woody\Downloads\phus-goagent-b17eb51\server\..\local\py25.exe" //盘符+路径
~dp是变量扩充
d既是扩充到分区号,即盘符"c:"
p就是扩充到路径,即"\Users\Woody\Downloads\phus-goagent-b17eb51\server\"
dp就是扩充到分区号路径,即"C:\Users\Woody\Downloads\phus-goagent-b17eb51\server\"
%0表示命令本身,即"C:\Users\Woody\Downloads\phus-goagent-b17eb51\server\uploader.bat"
订阅 博文 [Atom]