我有一个脚本删除我的Epson扫描文件夹中的所有文件。 如果我手动运行脚本,它可以很好地工作。 但出于某种原因,如果我在任务调度程序中设置任务,它不会删除文件? 有谁知道为什么会这样?
注意:pclist.txt只是个人电脑名称列表
@echo off for /F %%G in (pclist.txt) do ( pushd "\\%%G\C$\Epson Scans" || exit /B 1 for /D %%I in ("*") do ( rd /S /Q "%%~I" ) del /Q "*" popd )I have a script to delete all files in my Epson Scans Folder. If I run the script manually it works perfectly. But for some reason if I set up a task in task scheduler it does not delete the files? Does anyone know why this would happen?
Note: pclist.txt is just a list of pc names
@echo off for /F %%G in (pclist.txt) do ( pushd "\\%%G\C$\Epson Scans" || exit /B 1 for /D %%I in ("*") do ( rd /S /Q "%%~I" ) del /Q "*" popd )最满意答案
你确定文件pclist.txt位于'可能'的\Windows\system32目录中吗?
当作为计划任务运行时,当前目录不一定是以用户身份运行时使用的目录。
实现这一目标的最简单方法是将完整路径放在这些括号内,或者在@echo off下面添加以下行。
IF "%CD%\" NEQ "%~dp0" PUSHD "%~dp0"Are you sure that the file pclist.txt is located in 'probably' the \Windows\system32 directory?
When run as a Scheduled task the current directory will not necessarily be that used when run as a user.
The easiest way to achieve that is is to put that full path within those parentheses or to add the following line just beneath the @echo off.
IF "%CD%\" NEQ "%~dp0" PUSHD "%~dp0"更多推荐
发布评论