[英]Windows batch file execution log
I am executing a batch file in windows as below: 我正在Windows中执行一个批处理文件,如下所示:
EXEC MASTER..XP_CMDSHELL "\\remote-drive\\temp.bat" EXEC MASTER..XP_CMDSHELL“ \\ remote-drive \\ temp.bat”
How can I find out when was the last time this file was executed, how long it took to completely execute or any other information? 我如何才能知道该文件的上次执行时间,完全执行所花费的时间或其他任何信息?
ps I cannot edit the batch file in any way. ps我无法以任何方式编辑批处理文件。
Thank you in advance!! 先感谢您!!
don't run it directly; 不要直接运行它; build another batchfile to run it.
构建另一个批处理文件以运行它。 Something like:
就像是:
@echo off
>>mylogfile.txt echo started at %date% %time%
EXEC MASTER..XP_CMDSHELL "\remote-drive\temp.bat"
>>mylogfile.txt echo finished at %date% %time%
I don't understand EXEC MASTER..XP_CMDSHELL "\\remote-drive\\temp.bat"
If you want to run a batchfile, you should use call batchfile.bat
我不理解
EXEC MASTER..XP_CMDSHELL "\\remote-drive\\temp.bat"
如果要运行批处理文件,则应使用call batchfile.bat
SQL? SQL吗? Modified Stephan's answer : don't run it directly;
修改了斯蒂芬的答案 :不要直接运行它; build another batchfile
temp_with_log.bat
to run it. 构建另一个批处理文件
temp_with_log.bat
来运行它。 Something like: 就像是:
@echo off
>>mylogfile.txt echo started at %date% %time%
call "\remote-drive\temp.bat"
>>mylogfile.txt echo finished at %date% %time%
and run the following command 并运行以下命令
EXEC MASTER..XP_CMDSHELL "\remote-drive\temp_with_log.bat"
If the "\\remote-drive\\temp.bat"
contains EXIT
command without /B
switch, use start "" /W cmd /C
instead of call
as follows: 如果
"\\remote-drive\\temp.bat"
包含不带/B
开关的EXIT
命令 ,请使用start "" /W cmd /C
代替call
,如下所示:
@echo off
>>mylogfile.txt echo started at %date% %time%
start "" /W cmd /C "\remote-drive\temp.bat"
>>mylogfile.txt echo finished at %date% %time%
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.