on 06-08-2016 5:36 PM
Guys,
I am trying to run below command through Data Service using Script, this script will try to delete files older than 6 days, this works perfectly fine when i run from cmd prompt and i am getting exit code 1 error from DS, need expert help here.
print(exec('cmd.exe','forfiles /p "D:\\Test" /s /d -6 /c "cmd /c del @file"',1));
Error:
Job <DEL_SCRIPT> is terminated due to error <50306>.
Function <exec> failed to execute program <cmd.exe forfiles /p "D:\Test" /s /d -6 /c "cmd /c del @file">. Program terminated
with exit code <1>.
Thanks
Nitin
Make sure that you dont have (older than 6 days) sub-directories in the D:\Test folder. if sub-directories are there use below command:
print(exec('cmd.exe','forfiles /p "D:\\Test" /s /d -6 /c "cmd /c if @isdir==FALSE del /q @file"',1));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you sure the DS userid has the authorisations te delete from that folder?
Are you sure there's at least one file older than 6 days?
In any case, the command will run into an error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Of course, it works fine. There's nothing wrong with the command. If it works in Windows, it will also work in DS.
The main issue here, and it's always the same story, is that when run from DS, it's run from a different user with different authorisations than when you do it manually from the command prompt.
Hi Akhilesh,
Thanks for checking out this for me , finally i was able to get it resolved, by using below code, i realized forfiles was not getting recognized somehow, after providing the full path it worked.. Not sure of the reason though, may its not set properly in system variable ..
exec('cmd.exe','C:\\Windows\System32\forfiles.exe /p "F:\\Files\Nitin" /s /d -6 /c "cmd /c del @file"',8)
Thanks Again..
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.