batch-file - 批处理文件错误 : "Files was unexpected at this time."

标签 batch-file cmd

当我将 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/

相关文章:

batch-file - 在批处理脚本中回显到多个文件

windows - 使用 Windows 命令行查看文件是否存在并重命名

windows - CMD Findstr 与 ping

windows - 编译后命令提示符更改颜色

batch-file - 批处理脚本移动文件而不覆盖

batch-file - for循环的奇怪行为(批处理文件)

batch-file - 如何从 Windows 命令提示符以特定用户身份调用 PowerShell 脚本?

php - 从php以特定用户身份执行bat文件

windows - 哪些命令不能与 cmd 命令一起出现在一行/Windows 运行框中?

windows - 将 Echo 附加到较早的 Echo 上