从VBS调用批处理文件(多个命令行以获取输出) [英] Call Batch file (multiple command lines to get the output) from VBS
问题描述
我正在尝试编写VBscript来调用批处理文件.
我可以在命令提示符下执行某些操作,但是我无法从VBscript中执行相同的操作.
来自cmd:
I am trying to write a VBscript to call a batch file.
Something what I am able to do from Command prompt but i failed to do the same from VBscript.
From cmd:
C:\PR\PS\build\bin>execDl.bat Jack > History.txt \n
Jack> getHistory 50008 Dl \n
quit
我可以从脚本中调用第一步,但是我不明白如何执行第二步和第三步.到目前为止,我的脚本
I could call the 1st step from the script but i fail to understand how to do the 2nd and third step. till now my script
dim shell
dim ID
ID ="50008"
dim Deal
Deal ="Deal"
dim UserName
Deal ="admin"
dim OutputPoint
OutputPoint =">"
dim batchFileFolder
batchFileFolder = "C:\PR\PS\build\bin\"
set shell=createobject("wscript.shell")
strRun = batchFileFolder & "execDl.bat admin " & OutputPoint _
& batchFileFolder & "output1.txt" & """"
shell.run(strRun)
set shell=nothing
我们非常感谢您的帮助.
c:\ PR \ PS \ build \ bin> execDl.bat admin ------>在命令提示符下给出以下输出,然后光标指向admin
当前用户是:tswan
Any help is highly appreciated.
c:\PR\PS\build\bin>execDl.bat admin ------> gives out below output in command prompt and then the cursor points to admin
Current User is: tswan
欢迎使用FlowEngine Prototype命令行界面.
有关有效命令的列表,(在提示时输入帮助".
Welcome to FlowEngine Prototype command line interface.
For a listing of valid commands, (enter "help" at prompt.
admin> getHistory 7006 Dl
admin> getHistory 7006 Dl
文档活动历史记录:7006
Activity History for Document: 7006
流程提交于:2010-05-19 00:55:59.56
进程ID:3
提交者:swang
Process submitted on: 2010-05-19 00:55:59.56
Process id: 3
Submitter: swang
活动名称资源操作完成日期注释
Activity Name Resource Action Completion Date Comments
提交tswan提交2010-05-19 00:55:59.937 交易经理tswan批准2010-05-19 00:56:26.013 批准完成2010-05-19 00:56:26.027
Submit tswan Submit 2010-05-19 00:55:59.937 Deal Manager tswan Approve 2010-05-19 00:56:26.013 Approved Completed 2010-05-19 00:56:26.027
getHistory"7006 Dl"已成功完成.
getHistory "7006 Dl" has been successfully completed.
这是我在命令提示符下执行的命令的总体顺序,我在顶部提到的命令是将输出重定向到文本文件的三步命令.
this is the overall sequence of commands I follow in command prompt and the one i have mentioned at the top is the three step command to redirect output to the text file.
我的疑问是如何执行其余步骤,包括getHistory和VB脚本中的quit语句. :( @先生模糊按钮感谢您格式化它.我是stackoverflow发布方式的新手.
My doubt is how do i execute the rest of the step that includes getHistory and the quit statement from vb script. :( @Mr Fuzzy Button Thanks for formatting it. I am new to stackoverflow way of posting.
谢谢
推荐答案
基本上,您需要获取通常在FlowEngine提示符下键入的命令到文件中,然后从该文件中重定向标准输入.像这样:
Basically, you need to get the commands you would normally type at the FlowEngine prompt into a file and then redirect standard input from this file. Something like:
dim fso
dim f
dim cmd
dim shell
dim inpFile
dim outFile
inpFile = "execInput.txt"
outFile = "execOutput.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile( inpFile , 2, True)
f.Write "getHistory 50008 Deal" & vbCrLf & "quit" & vbCrLf
f.close
set shell=createobject("wscript.shell")
cmd = "execDeal.bat admin < " & inpFile & " > " & outFile
shell.run( cmd )
set shell=nothing
这篇关于从VBS调用批处理文件(多个命令行以获取输出)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!