Answers:
真是个好问题。这是我的解决方案(部分受Keltari的回答启发):
要求
snapshot_login_failure.cmd(使用ffmpeg.exe将其放置在某些文件夹中)
@echo off
:: Get date and time independent of regional settings. Source: http://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format-for-us
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
set datetime=%ldt:~0,4%_%ldt:~4,2%_%ldt:~6,2%_%ldt:~8,2%_%ldt:~10,2%_%ldt:~12,2%
:: Capture snapshot through DirectShow using FFmpeg and save to disk. Change name of video adapter and save path.
ffmpeg.exe -f dshow -i video="USB 2.0 UVC HD Webcam" -vframes 1 E:\snapshot_%datetime%.jpg
snapshot_login_failure.xml(将其作为Windows Scheduler任务导入)
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2013-07-06T23:32:34.0732602</Date>
<Author>Zoe\Zero3</Author>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
<Subscription><QueryList><Query Id="0" Path="Security"><Select Path="Security">*[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and EventID=4625]]</Select></Query></QueryList></Subscription>
</EventTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-19</UserId>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>E:\snapshot_login_failure.cmd</Command>
<WorkingDirectory>E:\</WorkingDirectory>
</Exec>
</Actions>
</Task>
笔记
很抱歉,恢复了旧线程,但是我将其发布给以后遇到此问题的人。
Zero3的流程在大多数情况下都是有效的,他对此感到非常好奇!但是,只有在启用失败登录尝试的日志记录后,然后使其右键单击日志中的事件ID,然后选择“将任务附加到此事件”,而不是通过XML导入任务,我才能使它起作用。使用权限,因为我必须输入管理员密码才能创建任务。
令我惊讶的另一件事是,触发的任务没有将.cmd文件识别为程序/脚本。为了解决这个问题,我在下面的代码与目录相同的目录中创建了一个简单的.bat文件,名为run.bat,而是让任务启动了批处理文件,从而运行了.cmd。
一种跳苏格兰式的方式使其工作,但由于有了这个线程,我对我的成功感到非常高兴,并且我很想为这个过程制作视频教程:)
非常感谢大家!
注意:我正在运行Windows 10 Pro x64
run.bat代码:
Start "" "C:\<filepath to .cmd>"
是的,如果您熟悉Windows MSGINA,则可以在理论上创建自定义登录事件,该事件将在笔记本电脑上启动相机并拍摄照片并将其保存到自定义文件夹中
参考:http : //technet.microsoft.com/en-gb/library/bb742447.aspx