Page 1 of 1

VBS and BAT parameters

Posted: 31 Jan 2020 14:18
by geojf3
I have the following .bat file being used to run a series of jobs to:
1) run a vbs script to calculate the previous weeks dates for Monday and Saturday
2) run a series of commands with the dates calculated to extract data from a commercial finance application
3) run a vbs script to load and run an Excel macro

The first part of the batch file is as follows:

Code: Select all

echo off
rem Get last weeks Monday-Saturday dates
for /F %%n in ('cscript.exe //nologo GetLastWeek.VBS') do set LastWeek=%%n
GetLastWeek.vbs is as follows:

Code: Select all

GetThisMonday = DateSerial(Year(Date), Month(Date), Day(Date) - DatePart("w", Date) + 1)
GetThisMonday=DateAdd("d",+1,GetThisMonday)
GetLastMonday=DateAdd("ww",-1,GetThisMonday)
GetLastSaturday=DateAdd("d",+6,GetLastMonday)
wscript.echo GetLastMonday
This will work fine for returning 1 date (GetLastMonday), but I also need the second date (GetLastSaturday).

What do I need to do to pass both values back to the bat file?

Thank you.

Re: VBS and BAT parameters

Posted: 31 Jan 2020 15:56
by penpen
The following might help you (untested; are you sure your vbs is correct?).

"test.bat":

Code: Select all

@echo off
setlocal enableExtensions disableDelayedExpansion
rem Get last weeks Monday-Saturday dates
for /F "tokens=* delims=" %%n in ('cscript.exe //nologo GetLastWeek.VBS') do set "%%~n"
set last
goto :eof
"GetLastWeek.VBS"

Code: Select all

GetThisMonday = DateSerial(Year(Date), Month(Date), Day(Date) - DatePart("w", Date) + 1)
GetThisMonday=DateAdd("d",+1,GetThisMonday)
GetLastMonday=DateAdd("ww",-1,GetThisMonday)
GetLastSaturday=DateAdd("d",+6,GetLastMonday)
wscript.echo "lastMonday=" & GetLastMonday
wscript.echo "lastSaturday=" & GetLastSaturday
penpen