Setting a windows batch file variable to the day of the week

后端 未结 17 1990
南方客
南方客 2020-11-27 20:14

I have a windows batch file that runs daily. Wish to log data into a file and want to rotate it (i.e. having at most the last 7 days worth of data).

Looked into the

17条回答
  •  臣服心动
    2020-11-27 21:00

    A version using MSHTA and javascript. Change %jsfunc% to whateve jscript function you want to call

    @echo off
    ::Invoke a javascript function using mhta
    
    set jsfunc=new Date().getDay()
    set dialog="about:"
    
    for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set ndow=%%p
    
    ::get dow string from array of strings  
    for /f "tokens=%ndow%"  %%d in ("Mon Tue Wed Thu Fri Sat Sun") do set dow=%%d 
    
    echo dow is : %ndow%  %dow%
    pause
    

提交回复
热议问题