Reputation: 443
I have a vbs file that calls a function which in turn runs a command. (I know this is convoluted, but it has to be done this way.) The issue I'm having is that I am passing a value into the function, which is supposed to pass that value as an argument to the command line. The msgbox in file1.vbs returns "10698441", as it should but the msgbox in file2.vbs is returning varRAW. I need this to show the true value of the variable. How can I get this variable to resolve to the correct value? I will also need the value created by file2.vbs saved into a variable. Is that possible?
file1.vbs:
fileAPPNUM("10698441")
function fileAPPNUM(varRAW)
msgbox varRAW
lresult = CreateObject("WScript.Shell").Run ("c:\windows\syswow64\cscript.exe file2.vbs varRAW",0,true)
end function
file2.vbs:
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="C:\temp\AppNum.txt"
Set objFile = objFSO.CreateTextFile(outFile,True)
Dim strCon
CAID=WScript.Arguments.Item(0)
msgbox CAID
strCon = "DSN=*****; " & _
"uid=********;pwd=*********;"
Dim oCon: Set oCon = WScript.CreateObject("ADODB.Connection")
Dim oRs: Set oRs = WScript.CreateObject("ADODB.Recordset")
oCon.Open strCon
Set oRs = oCon.Execute("select SPRCMNT_TEXT from SPRCMNT where SPRCMNT_TEXT like 'CA_%" + CAID + "%'")
objFile.write oRs.Fields(0).Value & vbCrLf
objFile.close
oCon.Close
Set oRs = Nothing
Set oCon = Nothing
Upvotes: 0
Views: 262
Reputation: 3464
Pass the value of varRAW like in .Run("... file2.vbs " & varRAW,0,true)
.
Upvotes: 1