use*_*308 4 windows path batch-file
我是批处理脚本编程的新手.如果我给出相对路径,则在执行批处理文件时获取错误.我有以下文件夹结构
Script folder - C:\batch\script\ServiceRegister.bat
Bin path - C:\batch\bin\ERecruitGenerateReportsWindowsService.exe
Run Code Online (Sandbox Code Playgroud)
ServiceRegister.bat批处理文件 -
%windir%\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe %~dp0%~1\bin\ERecruitGenerateReportsWindowsService.exe
Run Code Online (Sandbox Code Playgroud)
当我执行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.
Run Code Online (Sandbox Code Playgroud)
我正在使用"%~dp0%~1"在目录中向上移动一级仍然获取其当前路径.
%~dp0%~1 - C:\batch\script\
Run Code Online (Sandbox Code Playgroud)
我需要C:\ batch\path.我怎么能走这条路呢?它工作正常如果我给出绝对路径 -
%windir%\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe C:\batch\bin\ERecruitGenerateReportsWindowsService.exe
Run Code Online (Sandbox Code Playgroud)
dbe*_*ham 10
您尝试使用目标%~1结构中的一个级别是创造性的并且语法完全无效.正确的语法就是这么简单 - 使用..\.
\不需要领先,因为%~dp0以a结尾\.
%windir%\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe %~dp0..\bin\ERecruitGenerateReportsWindowsService.exe
Run Code Online (Sandbox Code Playgroud)