.bat file - Write a new variable to a .msl (.txt) file -
ok, follow-up another question had earlier. code finds previous business day , loops through hour-minute combinations between 3 , 9.
the code feed new variable .msl (basically .txt file our document direct server).
i need code write found variable .msl file , run file.
here have far:
@echo off setlocal enabledelayedexpansion echo wd = weekday^(date^(^), vbsunday^)>yesterday.vbs echo if wd ^< 3 dif = -1 - wd else dif = -1 >>yesterday.vbs echo d = dateadd^("d", dif, date^(^)^)>>yesterday.vbs echo wscript.echo datepart^("yyyy",d^) ^& " " ^& datepart^("m", d^) ^& " " ^& datepart^("d", d^) >>yesterday.vbs /f "tokens=1-3" %%i in ('cscript /nologo yesterday.vbs') ( set year=%%i if %%j leq 9 (set month=0%%j) else set month=%%j if %%k leq 9 (set day=0%%k) else set day=%%k ) del yesterday.vbs set yyyy=%year:~-4% set mm=%month:~-2% set dd=%day:~-2% set prevbusday=%yyyy%%mm%%dd% echo %prevbusday% pause /l %%g in (3,1,9) ( /l %%h in (0,1,59) ( set "h=0%%h" echo %prevbusday%0%%g!h:~-2! set "id=%prevbusday%0%%g!h:~-2!" break>test.msl (echo openview serverid 'mobius server ' reportid 'trialreports ' versionid ' **id** 'sectionid ' 0000-000 name of report' page 1)> test.msl (echo export ascii file 'c:\new folder\check.rpt' cursec group '') >> test.msl (echo close) >> test.msl rem **here add code call newly minted 'test.msl' - rem i'll later** ) ) pause
where says versionid ' id
need inject variable. i've tried in quotes , not , can't figure out how inject properly.
windows variables evaluated inline. have replace **id**
!id!
.
just feel i've done useful, i'll previous business day calculation well. can hybridize code , use jscript date()
object remove necessity of echoing out temporary .vbs script. moved redirect test.msl
parenthetical code block clean code bit. if msl handler allows, can dump openview...export...close
lines file , run handler once, might improve efficiency. see revision 2 of answer example.
i think want. save .bat extension.
@if (@codesection == @batch) @then @echo off setlocal enabledelayedexpansion /f %%i in ('cscript /nologo /e:jscript "%~f0"') set "prevbusday=%%i" echo %prevbusday% pause /l %%g in (3,1,9) ( /l %%h in (0,1,59) ( set "h=0%%h" set "id=%prevbusday%0%%g!h:~-2!" echo !id! >test.msl ( echo openview serverid 'mobius server ' reportid 'trialreports ' versionid ' !id! ' sectionid ' 0000-000 name of report' page 1 echo export ascii file 'c:\new folder\check.rpt' cursec group '' echo close ) rem **here add code call newly minted 'test.msl' - rem i'll later** ) ) pause goto :eof @end // end batch / begin jscript chimera var day = 1000 * 60 * 60 * 24, yesterday = new date().getday() - 1, prevbusday = new date(!yesterday?new date()-day*3:(yesterday<0?new date()-day*2:new date()-day)), y = [ prevbusday.getfullyear(), ('0' + (prevbusday.getmonth() + 1)).match(/\d\d$/)[0], ('0' + prevbusday.getdate()).match(/\d\d$/)[0] ] wsh.echo(y.join(''));
Comments
Post a Comment