Reputation: 49
I have the following .bat file being used to run a series of jobs to:
The first part of the batch file is as follows:
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:
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.
Upvotes: 0
Views: 296
Reputation: 38604
Here's one example of how I may do it in a batch-file:
<!-- :
@Echo Off
For /F "Tokens=1,2Delims=," %%G In ('^""%__AppDir__%cscript.exe" //NoLogo "%~f0?.wsf"^"'
)Do Set "LastMon=%%G"&Set "LastSat=%%H"
Rem Rest of code below here.
Set LastMon
Set LastSat
Pause
Rem No more code below here.
Exit /B
-->
<Job><Script Language="VBScript">
WScript.Echo(Date-Weekday(Date,vbTuesday)&","&Date-Weekday(Date,vbSunday))
</Script></Job>
Upvotes: 1
Reputation: 49
Someone previously made a comment here and then for some reason deleted it - but it go me thinking and trying some things I did not think of before. The following changes seem to work for what I was looking for:
wscript.echo GetLastMonday & "," & GetLastSaturday
for /f "tokens=1,2 delims=," %%A in ('cscript //nologo lastweek.vbs') do @echo %%A %%B
Upvotes: 0