如何将vbs保存在批处理文件中的多行命令中 [英] How to save vbs in batch file one command in multiple lines

查看:123
本文介绍了如何将vbs保存在批处理文件中的多行命令中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将vbs文件保存在这样的批处理文件中:

I would like to save a vbs file in a batch file like this:

echo set shell = createobject("wscript.shell")
wscript.sleep(1000)
shell.sendkeys("blablabla")
Shell.SendKeys "{Enter}"
wscript.sleep(1000) >"c:\folder\blablabla.vbs"

,但批处理文件不起作用.如果我这样做(如果我在一行中输入vbs代码):

but the batch file doesn't work. If I do it like this(If I type the vbs code in one line):

echo set shell = createobject("wscript.shell") wscript.sleep(1000) shell.sendkeys("blablabla") Shell.SendKeys "{Enter}" wscript.sleep(1000) >"c:\folder\blablabla.vbs"

然后vbs文件不起作用. 所以我的问题是:如何正确保存vbs文件,而又不让批处理文件认为我希望他执行多个命令.

then the vbs file doesn't work. So my question is: how can I save the vbs file correctly, without making the batch file think that I want him to do multiple commands.

推荐答案

首选:

使用组合运算符()组合您想要的命令,并使用^在代码中转义冲突的Batch运算符.

Agroupate the commands you wanr using the agroupation operators () and escape conflictive Batch operators in code using ^.

(
 echo set shell = createobject^("wscript.shell"^)
 echo wscript.sleep^(1000^)
 echo shell.sendkeys^("blablabla"^)
 echo Shell.SendKeys "{Enter}"
 echo wscript.sleep^(1000^)
)>"c:\folder\blablabla.vbs"

第二选择

要连接VBScript中的指令,您需要使用:运算符,那么多行代码应如下所示:

To concatenate instructions in VBScript you need to use the : operator, then an all-in-one line code should look like this:

echo set shell = createobject^("wscript.shell"^) : wscript.sleep^(1000^) : shell.sendkeys^("blablabla"^) : Shell.SendKeys "{Enter}" : wscript.sleep^(1000^) >"c:\folder\blablabla.vbs"

这篇关于如何将vbs保存在批处理文件中的多行命令中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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