Task Scheduler will not run when the user is logged off

Hi there,

I'm using Windows server 2008 R2 on one of my Pro Env, I have two batch files (See Block code)

Both should run when the user is logged off however only batch file number 1 is working

All setting are the same

any help will be great

P.S I'm straggling around this issue fora while, when running the tasks from cmd both running fine, when running the tasks from the task scheduler while logged on the tasks run fine as well.

The P:\ is a share drive on a nas

Batch 1:

set path="C:\Program Files\WinRAR\";%path%

cd D:\Xsense Services\Protocol\Logs

winrar a -df -ep -agDD-MMM-YYYY-NN Protocol_.rar -x*.txt

move *.rar \\xs-nas\Public\XS-App1\PP1

cd "D:\Xsense Services\ProtocolComm3\Logs"

winrar a -df -ep -agDD-MMM-YYYY-NN ProtocolComm3_.rar -x*.txt

move *.rar \\xs-nas\Public\XS-App1\PP3

cd "D:\Xsense Services\ProtocolZespri\Logs"

winrar a -df -ep -agDD-MMM-YYYY-NN ProtocolZespri_.rar -x*.txt

move *.rar \\xs-nas\Public\XS-App1\PP2

Exit

Batch 2

forfiles /p "P:\XS-App1\PP1" /s /m *.rar /c "cmd /c Del @path" -d -90
forfiles /p "P:\XS-App1\PP2" /s /m *.rar /c "cmd /c Del @path" /d -90
forfiles /p "P:\XS-App1\PP3" /s /m *.rar /c "cmd /c Del @path" /d -90
Exit

August 21st, 2015 9:39pm

According to the TechNet link below the command for "forfiles" is on windows 2008... If you have verified the the tool is present then I would try this for batch 2.

@Echo off
C:
cd\
cd "\windows\system32\"

forfiles /p "P:\XS-App1\PP1" /s /m *.rar /c "cmd /c Del @path" -d -90
forfiles /p "
P:\XS-App1\PP2" /s /m *.rar /c "cmd /c Del @path" /d -90
forfiles /p "
P:\XS-App1\PP3" /s /m *.rar /c "cmd /c Del @path" /d -90

:end

https://technet.microsoft.com/en-us/library/cc753551.aspx?f=255&MSPPError=-2147217396
Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 10:07pm

Hi,

I try your way and it didn't work.

I thought about it in another  server I have the same problem as well and I notice that in both server there is a map network drive and I'm beginning to think

that mark "Run when the user is logged on or not" is not working when it's come to a map drive, I also try to include net use in the script with user name

and password but that didn't help.

I think i should switch to "remove item" a power shell command

August 22nd, 2015 8:04am

update

issue has been fix here is the notes:

1. Before adding the "net use" to the script the scheduler error was 0x1

2. After adding "net use" the scheduler error was 0x8004131F more info can be found here:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa383604%28v=vs.85%29.aspx

After visit the page I change the rule under Setting " If the task is already running, then the following rule applies" and chose "Stop the existing instance"

Thx for your help

Manny

Free Windows Admin Tool Kit Click here and download it now
August 22nd, 2015 9:47am

Thank you for sharing your solutions and experience here. It will be very beneficial for other community members who have similar questions. 
 

Regards,

Eth

August 24th, 2015 3:39am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics