vbs 执行dos命令,加参数 求救
第一步从EXECL取2列的值
Dim xlsApp,wkBook,wkSheet,content
Set xlsApp=CreateObject("Excel.Application")
Set wkBook=xlsApp.Workbooks.Open("c:\TestData.xls")
Set wkSheet=wkBook.Worksheets("Sheet1")
For i=2 To 4
arg1=wkSheet.cells(i,1)
MsgBox arg1
arg2=wkSheet.cells(i,2)
MsgBox arg2
第2步调用BAT文件把参数arg1 arg2传给bat文件后面
Dim WshShell
set WshShell = CreateObject("wscript.Shell")
set aExec=WshShell.run("cmd /k cd c:\&run.bat arg1 arg2 > test.txt")
WshShell.SendKeys "{ENTER}"
run.bat文件的内容,BAT文件就是调用一个JAVA打包程序
@echo off
set WORKSTATION_HOME=%~dp0
java -cp test-case.jar com.ge.med.test.Calculator %1 %2 %3
sleep 5
[解决办法]
应该是set aExec=WshShell.run("cmd","/k cd c:\&run.bat arg1 arg2 > test.txt")