我有以下批处理文件:
"C:\TapTest\PsExec.exe" /accepteula -i -s "C:\TapTest\tapinstall.exe"
-> install "C:\TapTest\driver\OemWin2k.inf" tap0901
批处理文件的位置是:
c:\TapTest\TapInstall.bat
我希望能够执行以下操作(使用相对路径):
"PsExec.exe" /accepteula -i -s "tapinstall.exe" install "driver\OemWin2k.inf" tap0901
但是tapinstall.exe需要一个绝对路径作为参数。如何在没有硬编码的情况下获取批处理文件以提供绝对路径?
答案 0 :(得分:2)
"PsExec.exe" /accepteula -i -s "%~dp0tapinstall.exe" install "%~dp0driver\OemWin2k.inf" tap0901
%0
=对当前批处理文件的引用
%~dp0
=批处理文件所在的驱动器和路径