Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 指定批处理文件中需要绝对值的相对路径_Windows_Batch File_Relative Path_Absolute Path - Fatal编程技术网

Windows 指定批处理文件中需要绝对值的相对路径

Windows 指定批处理文件中需要绝对值的相对路径,windows,batch-file,relative-path,absolute-path,Windows,Batch File,Relative Path,Absolute Path,我有以下批处理文件: "C:\TapTest\PsExec.exe" /accepteula -i -s "C:\TapTest\tapinstall.exe" -> install "C:\TapTest\driver\OemWin2k.inf" tap0901 批处理文件的位置为: c:\TapTest\TapInstall.bat 我希望能够执行以下操作(使用相对路径): 但是tapinstall.exe需要一个绝对路径作为参数。如何让批处理文件给出绝对路径而不进行硬

我有以下批处理文件:

"C:\TapTest\PsExec.exe" /accepteula -i -s "C:\TapTest\tapinstall.exe" 
    ->  install "C:\TapTest\driver\OemWin2k.inf" tap0901
批处理文件的位置为:

c:\TapTest\TapInstall.bat
我希望能够执行以下操作(使用相对路径):

但是tapinstall.exe需要一个绝对路径作为参数。如何让批处理文件给出绝对路径而不进行硬编码

"PsExec.exe" /accepteula -i -s "%~dp0tapinstall.exe" install "%~dp0driver\OemWin2k.inf" tap0901
%0
=对当前批处理文件的引用

%~dp0
=批处理文件所在的驱动器和路径


谢谢你。我编辑了您的答案,将
%~dp0
也添加到
tapinstall.exe
中。它正在等待审核。@MC ND:如何在PowerShell中实现它..???@Koder101
$ScriptDirectory=Split Path$script:MyInvocation.MyCommand.Path
"PsExec.exe" /accepteula -i -s "%~dp0tapinstall.exe" install "%~dp0driver\OemWin2k.inf" tap0901