我是批处理编程的新手。如果我给出相对路径,在执行批处理文件时会出现错误。 我有以下文件夹结构
Script folder - C:\batch\script\ServiceRegister.bat
Bin path - C:\batch\bin\ERecruitGenerateReportsWindowsService.exe
ServiceRegister.bat Batch file –
%windir%\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe %~dp0%~1\bin\ERecruitGenerateReportsWindowsService.exe
执行ServiceRegister.bat文件时,我收到了以下错误提示:
Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\batch\script\bin\ERecruitGenerateReportsWindowsService.exe' or one of its dependencies. The system cannot find the file specified.
我正在使用“%~dp0%~1”命令向上一级目录跳转,但它仍然获取当前路径。
%~dp0%~1 - C:\batch\script\
我需要获取 C:\batch\ 路径。我该如何获得这个路径? 如果我提供绝对路径,它可以正常工作 -
%windir%\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe C:\batch\bin\ERecruitGenerateReportsWindowsService.exe