当我将 path
作为我的第二个参数传递时,出现以下错误。看起来问题出在空间上。
此时文件是意外的
我正在执行带有以下参数的批处理文件
services.cmd 2 "C:\Program Files (x86)\folder\Folder\folder\Bin"corp\acct 密码
代码:
@echo off
if "%1" == "" goto PARAMS
if "%2" == "" goto PARAMS
if "%3" == "" goto PARAMS
if "%4" == "" goto PARAMS
sc create "<service name>"%1 binpath= "\%2\xxx.exe\" \"xxx.exe.config\""
rem sc config "<service name>"%1 displayname= "<display name>"%1 obj= %3 password= %4 start= auto description= "Runs the service."
goto END
:PARAMS
echo Usage CreateServices.cmd binfoldername binfolderpath username password
:END
最佳答案
您不能在带引号的字符串中转义引号。使用 %~2
去除参数中不需要的引号。
尝试以下操作:
sc create "<service name>%~1" binpath= "%~2\xxx.exe" "xxx.exe.config"
关于batch-file - 批处理文件错误 : "Files was unexpected at this time.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21602348/