在msdeploy runco​​mmand中将参数传递给批处理文件 [英] pass parameters to batch file in msdeploy runcommand

查看:114
本文介绍了在msdeploy runco​​mmand中将参数传递给批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使它正常工作

call "%MSDeployPath%msdeploy" -verb:sync -source:runCommand='backup.bat param1' -dest:auto,computername=10.xx.xx.xx,username=xxx,password=yyy

它给了我

警告:"backup.bat"未被识别为内部或外部 命令,可运行的程序或批处理文件.

Warning: 'backup.bat' is not recognized as an internal or external command, operable program or batch file.

警告:进程"C:\ Windows \ system32 \ cmd.exe"(命令行") 退出,代码为"0x1".更改总数:1(添加0,删除0,1 更新,更改了0个参数,复制了0个字节)

Warning: The process 'C:\Windows\system32\cmd.exe' (command line '') exited with code '0x1'. Total changes: 1 (0 added, 0 deleted, 1 updated, 0 parameters changed, 0 bytes copied)

如果我删除了param1并将其在.bat中进行硬编码,则它可以工作,因此bat文件也没有问题,以防万一.

If I remove the param1 and hardcode it inside the .bat, it works, so there's no problem with the bat file, in case you wonder.

我试图指定.bat的完整路径,但仍然不起作用:

I tried to specify the full path to .bat and it still doesn't work:

call "%MSDeployPath%msdeploy" -verb:sync -source:runCommand='c:\backup.bat param1' -dest:auto,computername=10.xx.xx.xx,username=xxx,password=yyy

在这种情况下,看起来好像将路径解释为远程路径,它希望backup.bat位于服务器上.我在服务器上移动了backup.bat后,这一点向我确认,它可以正常工作

In this case, it looks like it interprets the path as a remote path, it expects backup.bat to be on the server. This was confirmed to me after I moved backup.bat on the server, it worked

为什么一定要这么硬?

推荐答案

编辑是的,

Edit You are right, the documentation states that cmd/bat files will be streamed to the destination.

在我看来,这只是它不能接受参数的功能的限制.在部署时使用硬编码设置创建批处理文件的修改版本应该不会太困难.

It seems to me that it's simply a limitation of the feature that it can't accept arguments. It shouldn't be too difficult to create a modified version of the batch file at deploy-time with the settings hardcoded.

类似的东西:

REM Start of prepended script
SET SCRIPT_USERNAME=ThatGuy
REM End of prepended script

IF ("%SCRIPT_USERNAME%" == "") SET SCRIPT_USERNAME=%1

更新浏览了msdeploy的反射源(ahem),我可以确认这只是当前设计的方式.它根据整个路径是否代表文件来确定是否上传文件.由于添加参数会阻止其解析文件的路径,因此它不会上传任何内容.

Update Having browsed the reflected source (ahem) of msdeploy, I can confirm that it's simply the way it's current designed. It determines whether to upload the file based on whether the entire path represents a file. Since adding arguments will prevent it resolving the path to a file, it doesn't upload anything.

这篇关于在msdeploy runco​​mmand中将参数传递给批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆