I have a vbs code like:
我有一个类似的vbs代码:
Message4 = "Please enter Check Out Path"
Title4 = "Check Out Path "
variable1 = InputBox(Message4, Title4,"", 4500, 4500)
Message5 = "Please enter SVN URL"
Title5 = "SVN URL "
variable2 = InputBox(Message5, Title5, "", 4500, 4500)
Folder\batchfile.bat"""
objWshell.Run "batxhfile.bat"
and also batch file named batchfile.bat
以及名为batchfile.bat的批处理文件
@echo off
Color 42
echo. [ SVN Updater ]
set Checkout_path=checkout path
set SVN=C:\Program Files\TortoiseSVN\bin
set svn_url=SVN path
echo. Updating %Checkout_path% to SVN...
"%SVN%\TortoiseProc.exe" /command:checkout /url:"%svn_url%" /path:"%Checkout_path%" /closeonend:2
echo. done.
echo.
echo. Operation complete.
Now i want to pass the value of variable1
and variable2
from vbs code to batch file in the place of checkout path
and svn path
i have tried lots of method but no success uptill plz help.
现在我想将vs代码中的variable1和variable2的值传递给checkout路径和svn路径的批处理文件我已经尝试了很多方法但是没有成功uptill plz帮助。
1 个解决方案
#1
0
I agree why you wouldn't simply call 'TortoiseProc.exe' from a VBS, however you may have you reasons for calling via a batch script. Simply pass arguments into a batch from a VBS:
我同意你为什么不简单地从VBS调用'TortoiseProc.exe',但是你可能有理由通过批处理脚本调用。只需将参数从VBS传递到批处理:
`Const ERR_SUCCESS = 0
Const BAT_SCRIPT = "<folder>\batchfile.bat"
Dim oWSH, sCmd, iRC, sVar1, sVar2
Set oWSH = WScipt.CreateObjects("WScript.Shell")
Do While sVar1 <> ""
sVar1 = InputBox("Please enter Check Out Path", "Check Out Path", 4500, 4500)
Loop
Do While sVar2 <> ""
sVar2 = InputBox("Please enter SVN URL", "SVN URL", 4500, 4500)
Loop
sCmd = "cmd.exe /c """ & BAT_SCRIPT & "" "" & sVar1 & "" "" & sVar2 & """"
WScript.Echo "COMMAND: sCmd"
On Error Resume Next
iRC = oWSH.Run(sCmd, 0, True)
If iRC <> ERR_SUCCESS And Err.Number <> ERR_SUCCESS Then
MsgBox "ERROR: [" & Err.Source & "] " & CStr(Err.Number) & " - " & Err.Description & vbCrLf & _
" '" & BAT_SCRIPT "' return code = '" & CStr(iRC) & "' from command:" & vbCrLf & _
" COMMAND: " & sCmd, vbOkOnly, "Batch Script Error"
End If
Err.Clear
Set oWSH = Nothing`
You're result batch script command should be called like the following:cmd.exe /c "<folder>\batchfile.bat" "<var1>" "<var2>"
您应该调用结果批处理脚本命令,如下所示:cmd.exe / c“
Ensure your batch script gathers arguments, removes string double quotes and validates correctly:
确保批处理脚本收集参数,删除字符串双引号并正确验证:
`set Checkout_path=%1
set Checkout_path=%Checkout_path:~1,-1%
set svn_url=%2
set svn_url=%svn_url:~1,-1%
if /i "%Checkout_path%" ne "" (
exit /b 99
)
if /i "%svn_url%" ne "" (
exit /b 99
)`
Hope this helps ;)
希望这可以帮助 ;)
#1
0
I agree why you wouldn't simply call 'TortoiseProc.exe' from a VBS, however you may have you reasons for calling via a batch script. Simply pass arguments into a batch from a VBS:
我同意你为什么不简单地从VBS调用'TortoiseProc.exe',但是你可能有理由通过批处理脚本调用。只需将参数从VBS传递到批处理:
`Const ERR_SUCCESS = 0
Const BAT_SCRIPT = "<folder>\batchfile.bat"
Dim oWSH, sCmd, iRC, sVar1, sVar2
Set oWSH = WScipt.CreateObjects("WScript.Shell")
Do While sVar1 <> ""
sVar1 = InputBox("Please enter Check Out Path", "Check Out Path", 4500, 4500)
Loop
Do While sVar2 <> ""
sVar2 = InputBox("Please enter SVN URL", "SVN URL", 4500, 4500)
Loop
sCmd = "cmd.exe /c """ & BAT_SCRIPT & "" "" & sVar1 & "" "" & sVar2 & """"
WScript.Echo "COMMAND: sCmd"
On Error Resume Next
iRC = oWSH.Run(sCmd, 0, True)
If iRC <> ERR_SUCCESS And Err.Number <> ERR_SUCCESS Then
MsgBox "ERROR: [" & Err.Source & "] " & CStr(Err.Number) & " - " & Err.Description & vbCrLf & _
" '" & BAT_SCRIPT "' return code = '" & CStr(iRC) & "' from command:" & vbCrLf & _
" COMMAND: " & sCmd, vbOkOnly, "Batch Script Error"
End If
Err.Clear
Set oWSH = Nothing`
You're result batch script command should be called like the following:cmd.exe /c "<folder>\batchfile.bat" "<var1>" "<var2>"
您应该调用结果批处理脚本命令,如下所示:cmd.exe / c“
Ensure your batch script gathers arguments, removes string double quotes and validates correctly:
确保批处理脚本收集参数,删除字符串双引号并正确验证:
`set Checkout_path=%1
set Checkout_path=%Checkout_path:~1,-1%
set svn_url=%2
set svn_url=%svn_url:~1,-1%
if /i "%Checkout_path%" ne "" (
exit /b 99
)
if /i "%svn_url%" ne "" (
exit /b 99
)`
Hope this helps ;)
希望这可以帮助 ;)