Along those lines, replace C:\Windows with %windir%:
%windir%\System32\Forfiles.exe

Or, as an alternative, take the path out of the forfiles statement:
C:
CD \inetpub\ftproot\SystemiJrnRcvrs
%windir%\System32\Forfiles.exe -c "cmd /c del @FILE" -d -%AgeLimit% -m
MASTER*


On Thu, Dec 5, 2013 at 1:02 PM, CRPence <CRPbottle@xxxxxxxxx> wrote:

On 04-Dec-2013 11:10 -0800, Jeff Crosby wrote:
C:\Windows\System32\Forfiles.exe
-p "C:\inetpub\ftproot\SystemiJrnRcvrs"
-c "cmd /c del @FILE" -d -%AgeLimit% -m MASTER*

Note that the full path is in there.

If I run the batch file directly in a command window or just
double-click it in Windows explorer, it runs fine. If I try to run it
from the task scheduler (either by the time trigger or right-click
and Run) it failswith opcode 2.

Should that be "Error Code 2"? A web search for an error code 2
yielded what possibly are some good topics to review. One suggests
using @PATH@FILE instead of just @FILE. Another suggests that a problem
will remain if the path or file name has embedded blanks, so the double
quote delimiter must be included; shown un-escaped in the -c switch so
like:
"cmd /c del "@PATH@FILE""

My web search:
<https://www.google.com/search?&q="forfiles"+"error+2"+OR+"error+code+2";>

--
Regards, Chuck
--
This is the PC Technical Discussion for IBM i (AS/400 and iSeries) Users
(PcTech) mailing list
To post a message email: PcTech@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/pctech
or email: PcTech-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/pctech.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.