In continuation to the script provided by rojo at escape double quotes in param file to batch script, after I have parsed the initial data file, I need to invoke a .vbs script from the batch. The .vbs script needs to be supplied with 2 of the tokens generated by parsing the initial data file. One of the token is a URL to a file on a server and another is the path on local disk. The .vbs script downloads the specified file specified by token one to local path specified by token two. What I want to do is to invoke the .vbs script in the script above and pass the tokens as parameters to it. myvbscript.vbs /FileURL:"https://abc.com/a.pdf" /HDLocation:"C:\a.pdf"
Here is the .bat file i have.
@if(@a==@b) @end
/* :: batch portion
@ECHO OFF
setlocal if exist "%~1"
( cscript /nologo /e:jscript "%~f0" < "%~1" )
else ( cscript /nologo /e:jscript "%~f0" )
exit /b
:: JScript portion */
while (!WSH.StdIn.AtEndOfLine) {
var line=WSH.StdIn.ReadLine();
var st_token = line.split('\t');
var FileUR="abc.com/a.pdf";
var HDLocation="C:\a.pdf";
WSH.Echo(req_id);
WSH.Echo(att_tokens[i]);
<<INVOKE VBSCRIPT WITH PARAMETERS>>
I need to invoke vbscript in place of <<INVOKE VBSCRIPT WITH PARAMETERS>>
Please help}
Please help me to invoke the .vbs script in the script above with passing tokens as parameters.
The .vbs script is as follows:
'Set your settings
Set colNamedArguments = WScript.Arguments.Named
strFileURL = colNamedArguments.Item("FileURL")
strHDLocation = colNamedArguments.Item("HDLocation")
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing