好的,这是another question I had earlier的后续行动。我的代码找到上一个工作日,然后遍历3到9之间的所有小时 - 分钟组合。
代码将这个新变量提供给.msl(基本上是我们文档直接服务器的.txt文件)。
如果小时数的正确组合是正确的,它会吐出检查报告。
我的代码在每个循环中检查该报告。一旦发现'检查'报告,它需要使用主代码写入更大的.msl文件来提取主要报告。
问题:
当我的电脑被锁定时,我需要这个过夜。我已将其设置为使用Windows任务计划程序自动运行。我没有退出,计算机已锁定。现在,批处理文件到达type NUL > test.msl
时出错。我认为这与从锁定屏幕写入的文件无关。我想知道是否有办法在test.msl
的整个文件路径中写入。像C:\UserID\folder\test.msl
一样执行。
以下是我到目前为止的情况,当我手动启动它时,此代码工作正常,但在计算机锁定时计划运行时则不行:
@if (@CodeSection == @Batch) @then
@ECHO off
setlocal enabledelayedexpansion
rem // invoke JScript chimera to get the YYYYMMDD of the previous work day
for /f %%I in ('cscript /nologo /e:JScript "%~f0"') do set "prevbusday=%%I"
echo %prevbusday%
type NUL > test.msl
type NUL > DailyFile.msl
For /L %%G IN (3,1,8) DO (
For /L %%H IN (0,1,59) DO (
set "h=0%%H"
type NUL > test.msl
ECHO %prevbusday%0%%G!h:~-2!
set "id=%prevbusday%0%%G!h:~-2!"
(echo OPENVIEW SERVERID 'Mobius Server ' REPORTID 'MGREPORTS ' VERSIONID ' !id! 'SECTIONID ' 0000-006 FILE/TABLE ERRORS' PAGE 1)>> test.msl
(echo EXPORT ASCII FILE 'S:\Automation\Document Direct Automation\Check\check.rpt' CURSEC GROUP '')>> test.msl
(echo CLOSE) >> test.msl
PING 1.1.1.1 -w 1000 -n 1
Start test.msl
PING 1.1.1.1 -w 1000 -n 1
start passwordinjector.vbs
PING 1.1.1.1 -w 500 -n 1
IF EXIST "S:\Automation\Document Direct Automation\Check\check.rpt" (
echo It exists!
taskkill /IM MAINRDW.exe /f >nul 2>&1
PING 1.1.1.1 -w 1000 -n 1
pause
(echo OPENVIEW SERVERID 'Mobius Server ' REPORTID 'MGREPORTS ' VERSIONID ' !id! 'SECTIONID ' 0019-001 069' PAGE 1) >> DailyFile.msl
(echo EXPORT ASCII FILE 'S:\Automation\Monarch\c&d.rpt' CURSEC GROUP '') >> DailyFile.msl
(echo CLOSE) >> DailyFile.msl
(echo OPENVIEW SERVERID 'Mobius Server ' REPORTID 'MGREPORTS ' VERSIONID ' !id! 'SECTIONID ' 0019-001 0' PAGE 1) >> DailyFile.msl
(echo EXPORT ASCII FILE 'S:\Automation\Monarch\exec hold.rpt' CURSEC GROUP '') >> DailyFile.msl
(echo CLOSE) >> DailyFile.msl
(echo OPENVIEW SERVERID 'Mobius Server ' REPORTID 'MGREPORTS ' VERSIONID ' !id! 'SECTIONID ' 0019-001 65' PAGE 1) >> DailyFile.msl
(echo EXPORT ASCII FILE 'S:\Automation\Monarch\fl outreach rev.rpt' CURSEC GROUP '') >> DailyFile.msl
(echo CLOSE) >> DailyFile.msl
(echo OPENVIEW SERVERID 'Mobius Server ' REPORTID 'MGREPORTS ' VERSIONID ' !id! 'SECTIONID ' 1144-001' PAGE 1) >> DailyFile.msl
(echo EXPORT ASCII FILE 'S:\Automation\Monarch\litigation.rpt' CURSEC GROUP '') >> DailyFile.msl
(echo CLOSE) >> DailyFile.msl
(echo OPENVIEW SERVERID 'Mobius Server ' REPORTID 'MGREPORTS ' VERSIONID ' !id! 'SECTIONID ' 0291-001 CASE' PAGE 1) >> DailyFile.msl
(echo EXPORT ASCII FILE 'S:\Automation\Monarch\lm flag.rpt' CURSEC GROUP '') >> DailyFile.msl
(echo CLOSE) >> DailyFile.msl
(echo OPENVIEW SERVERID 'Mobius Server ' REPORTID 'MGREPORTS ' VERSIONID ' !id! 'SECTIONID ' 0019-001' PAGE 1) >> DailyFile.msl
(echo EXPORT ASCII FILE 'S:\Automation\Monarch\recourse.rpt' CURSEC GROUP '') >> DailyFile.msl
(echo CLOSE) >> DailyFile.msl
(echo OPENVIEW SERVERID 'Mobius Server ' REPORTID 'MGREPORTS ' VERSIONID ' !id! 'SECTIONID ' 0285-002 ' PAGE 1) >> DailyFile.msl
(echo EXPORT ASCII FILE 'S:\Automation\Monarch\repay.rpt' CURSEC GROUP '') >> DailyFile.msl
(echo CLOSE) >> DailyFile.msl
(echo RUN "S:\Automation\BAT files\daily.bat") >> DailyFile.msl
PING 1.1.1.1 -w 1000 -n 1
Start DailyFile.msl
PING 1.1.1.1 -w 1000 -n 1
start passwordinjector.vbs
PING 1.1.1.1 -w 3000 -n 1
Del "S:\Check\check.rpt"
exit
) ELSE (
echo It doesn't exist :(
PING 1.1.1.1 -w 500 -n 1
taskkill /IM MAINRDW.exe /f >nul 2>&1
)
)
)
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(''));