bat calling vbscript

J

jg

I hope this is the right newsgroup

I saw my .bat file setting environment variable from result of vbscript
but the value disappear right away!!
c:\>set DtRapidLstDnlod=2005-11-29 18:38:00
when the bat file was executing

echo 2005-11-29 18:38:00| For /F "usebackq tokens=1-2" %%i in (`cscript
//nologo
"D:\util -misc\ConvertMMM_DD_HH_MM.vbs" `) do set DtRapidLstDnlod=%%i %%j

in a nut shell the problematic bat file statements are
echo 2005-11-29 18:38:00 | For /F "usebackq tokens=1-2" %%i in (`cscript
//nologo
"D:\util -misc\ConvertMMM_DD_HH_MM.vbs" `) do set DtRapidLstDnlod=%%i %%j
echo @debug DtRapidLstDnlod=%DtRapidLstDnlod%

@@rem end of bat file
Now I see output

c:\>set DtRapidLstDnlod=2005-11-29 %J

@debug DtRapidLstDnlod=


here is the code for vbs file
dim newDt , sDt, str
str = wscript.stdIn.ReadLine
newDt = Cdate(str)
sDt = "" & newDT
if len(sDt) = 17 then
sDt = "20" & sDt
End If

wscript.echo sDt

where did I go wrong? or is there a better to get result out of a script
excution.

from the output the vbscript does seem to function correctly, but somehow,
the value of variable being set gets lost. and become some funny empty
value.

I would have used vbscript for the entire task except I get in trouble with
some file IO when used cmoonad FTP. At times the redirected output of FTP
is not availabe to the script when it should.. Furthermore, I already have
a template for the batch file for the task.
 
M

Mike Lewis

I think you are losing the time portion of your string while passing it.
The space acts as an argument separator when you call VBS. Here's a bit of
code for recombining the datetime into one variable.

dim args
dim num

set args = WScript.Arguments
num = args.count

if num > 1 then
strDate = args.Item(0)
strDate = strDate & " " & args.Item(1)
elseif num = 1 then
strDate = args.Item(0)
else
' error?
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top