Hi,

I call a vbscript file from my batch file. I need to pass a variable from this vbscript file to batch file. can anyone please let me now how to do this.
batch file looks like this

cmd.bat
------------

@ECHO OFF
cscript "D:\samp.vbs "

isql -S sername -d dbname -U usrname -P %pwd% -q "select * from Table"


vbscript file
---------------
Option Explicit
Dim temp
temp = "hello"
key = "abcd123"
temp = sampfunc(temp,key)

Function sampfunc(str,key)
Dim lenKey, KeyPos, LenStr, x, Newstr

Newstr = ""
lenKey = Len(key)
KeyPos = 1
LenStr = Len(Str)

str=StrReverse(str)
For x = LenStr To 1 Step -1
Newstr = sample statements
KeyPos = KeyPos+1
If KeyPos > lenKey Then KeyPos = 1
Next
Newstr=StrReverse(Newstr)
Decrypt = Newstr
End Function

I need to pass the Newstr string which is my password onto my isql statement in the batch file. Can anyone help me on this

Thanks in advance
Vidya

Hi,

I call a vbscript file from my batch file. I need to pass a variable from this vbscript file to batch file. can anyone please let me now how to do this.
batch file looks like this

cmd.bat
------------

@ECHO OFF
cscript "D:\samp.vbs "

isql -S sername -d dbname -U usrname -P %pwd% -q "select * from Table"


vbscript file
---------------
Option Explicit
Dim temp
temp = "hello"
key = "abcd123"
temp = sampfunc(temp,key)

Function sampfunc(str,key)
Dim lenKey, KeyPos, LenStr, x, Newstr

Newstr = ""
lenKey = Len(key)
KeyPos = 1
LenStr = Len(Str)

str=StrReverse(str)
For x = LenStr To 1 Step -1
Newstr = sample statements
KeyPos = KeyPos+1
If KeyPos > lenKey Then KeyPos = 1
Next
Newstr=StrReverse(Newstr)
Decrypt = Newstr
End Function

I need to pass the Newstr string which is my password onto my isql statement in the batch file. Can anyone help me on this

Thanks in advance
Vidya

why need a batch file, just use vbscript to execute that isql command line..from the script..take a look at this on how to execute an exe file from vbscript

Set wshShell = WScript.CreateObject ("WSCript.shell")
 wshshell.run "c:\windows\system32\calc.exe "
 set wshshell = nothing

:)

thanks for your reply :)
I am currently using the batch file to access my database and I am advised not to change the batch file and only add method to retrieve password rather than text it.

Any suggestion are most welcome.

Regards,
Vidya

Hi,
I applied the below in the batch file and it worked. thanks!

for /f "tokens=*" %%a in ('cscript//nologo samp.vbs') do set var=%%a
echo.%var%

Regards,
Vidya

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.