如何根据批处理文件中的当前日期获取上周日日期。为了获得当前日期,我正在使用此...
echo %date:~-3,2%\%date:~7,2%\%date:~10,4%
答案 0 :(得分:0)
@if (@x)==(@y) @end /***** jscript comment ******
@echo off
for /f "delims=" %%d in ('cscript //E:JScript //nologo "%~f0"') do set "p_sund=%%d"
echo %p_sund%
exit /b 0
***** end comment *********/
var beforeOneWeek = new Date(new Date().getTime() - 60 * 60 * 24 * 7 * 1000)
, day = beforeOneWeek.getDay()
, diffToMonday = beforeOneWeek.getDate() - day + (day === 0 ? -6 : 1)
, lastMonday = new Date(beforeOneWeek.setDate(diffToMonday))
, lastSunday = new Date(beforeOneWeek.setDate(diffToMonday + 6));
WScript.Echo(beforeOneWeek);
编辑如果禁用了Windows脚本宿主exe,则使用mshta cab:
@if (@x)==(@y) @end /***** jscript comment ******
@echo off
for /f "delims=" %%d in ('cscript //E:JScript //nologo "%~f0"') do set "p_sund=%%d"
rem echo %p_sund%
Echo ^<html^>^<head^>>"temp.hh"
Echo ^<hta:application windowstate="minimize"^>>>"temp.hh"
Echo ^<script type="text/jscript" src="%~nx0"^>>>"temp.hh"
Echo ^</script^>^</head^>^</html^>>>"temp.hh"
Mshta.exe "temp.hh"
type temp.res
del /q /f "temp.hh" ""temp.res"" >nul 2>&1
exit /b 0
***** end comment *********/
var beforeOneWeek = new Date(new Date().getTime() - 60 * 60 * 24 * 7 * 1000)
, day = beforeOneWeek.getDay()
, diffToMonday = beforeOneWeek.getDate() - day + (day === 0 ? -6 : 1)
, lastMonday = new Date(beforeOneWeek.setDate(diffToMonday))
, lastSunday = new Date(beforeOneWeek.setDate(diffToMonday + 6));
WScript.Echo(beforeOneWeek);
var objFSO=new ActiveXObject("Scripting.FileSystemObject");
var outFile="temp.res";
var objFile = objFSO.CreateTextFile(outFile,true);
objFile.Write(beforeOneWeek);
objFile.Close();
稍后会考虑PowerShell解决方案。