当我从提升的命令提示符或右键单击 -> 以管理员身份运行时,我的 BAT 文件(如下)运行完美。但是,当我将它放入我的 Windows 10 任务计划程序时,它不会运行。
我尝试过的: -- 任务的安全选项:我尝试过 SYSTEM 和域管理员帐户。-- 我选择“以最高权限运行”。-- 我在“配置为:”下拉列表中选择了“Windows 10”。-- 在 EDIT ACTION 窗口中,我在“Start in (optional)”部分指定了 BAT 文件的位置 (c:\script) -- 在“Program/Script”中我尝试了“C:\scripts\script .bat"(不带引号)。我尝试仅列出“script.bat”(不带引号)。而且,我也尝试过“.\script.bat”(不带引号)。-- 在尝试将文件复制到网络驱动器之前,我在 BAT 文件中创建了额外的行以将文件从 System32 目录复制到另一个(不太安全的)位置。(我觉得这是不必要的,它没有'
*******************开始BAT文件******************
@Echo off
REM (maps network drive)
NET use Z: \\SERVER\PATH
REM (copies any archived security event viewer logs to the network)
IF EXIST "%SystemRoot%\System32\Winevt\Logs\Archive-Securit*.evtx" (
xcopy "%SystemRoot%\System32\Winevt\Logs\Archive-Securit*.evtx" c:\test\ /Y
xcopy "c:\test\Archive-Securit*.evtx" \\SERVER\PATH\%computername% /Y
REM (deletes files on the local machine after the files are verified to be on the network share)
FORFILES /p "Z:\PATH\%computername%" /c "cmd /c del %SystemRoot%\System32\Winevt\Logs\@file"
FORFILES /p "Z:\PATH\%computername%" /c "cmd /c del c:\test\@file"
) ELSE (
REM Do nothing
)
******************结束BAT文件***************