Solved Task Scheduler claims succesful, but is not

FredY42

New member
Local time
3:32 PM
Messages
7
I have created a new task, placed it in the scheduler, it runs on schedule, but I get no output.
If I double click the task it works.

My task is this: c:\users\fred\desktop\tr.bat
****************** echo off
echo. >> tracelog.txt
echo --------------------------------------------------------- >> tracelog.txt
echo Date: %date% Time: %time% >> tracelog.txt
echo --------------------------------------------------------- >> tracelog.txt
echo on
tracert -4 207.118.111.181 >> tracelog.txt
tracert -4 lax.testmy.net >> tracelog.txt
rem tracert -4 sf.testmy.net >> tracelog.txt
exit
****************

Output when started manually:
***********************
---------------------------------------------------------
Date: Sun 04/23/2017 Time: 10:11:06.66
---------------------------------------------------------

Tracing route to 207-118-111-181.dyn.centurytel.net [207.118.111.181]
over a maximum of 30 hops:

1 <1 ms <1 ms <1 ms modem.Home [192.168.0.1]
2 24 ms 23 ms 24 ms rb2-bras-sea.core.centurylink.net [63.231.10.152]
3 76 ms 76 ms 75 ms 207-118-111-181.dyn.centurytel.net [207.118.111.181]

Trace complete.

Tracing route to lax.testmy.net [172.98.72.95]
over a maximum of 30 hops:

1 <1 ms <1 ms <1 ms modem.Home [192.168.0.1]
2 24 ms 23 ms 27 ms rb2-bras-sea.core.centurylink.net [63.231.10.152]
3 24 ms 24 ms 24 ms tukw-agw1.inet.qwest.net [71.217.187.9]
4 23 ms 24 ms 24 ms sea-brdr-02.inet.qwest.net [67.14.41.190]
5 24 ms 25 ms 24 ms be209.ccr21.sea02.atlas.cogentco.com [154.54.11.1]
6 25 ms 28 ms 25 ms be2084.ccr22.sea01.atlas.cogentco.com [154.54.0.253]
7 44 ms 43 ms 43 ms be2077.ccr22.sfo01.atlas.cogentco.com [154.54.0.241]
8 44 ms 43 ms 44 ms be3179.ccr22.sjc01.atlas.cogentco.com [154.54.43.150]
9 53 ms 53 ms 52 ms be3177.ccr22.lax01.atlas.cogentco.com [154.54.40.145]
10 53 ms 55 ms 54 ms be2020.rcr22.lax04.atlas.cogentco.com [154.54.7.186]
11 52 ms 54 ms 54 ms te0-0-1-3.agr12.lax04.atlas.cogentco.com [154.24.35.18]
12 54 ms 53 ms 53 ms te0-0-2-0.nr11.b002695-2.lax04.atlas.cogentco.com [154.24.29.94]
13 52 ms 53 ms 53 ms as46562.demarc.cogentco.com [38.88.196.166]
14 54 ms 53 ms 53 ms vl51.dist-aa.lax01.as46562.net [104.200.152.57]
15 52 ms 53 ms 53 ms lax.testmy.net [172.98.72.95]

Trace complete.
**************************
A query of the task scheduler using schtasks (last screen shot) shows it is running.

Anybody have a clue?

Thanks for your time, Fred
 

Attachments

  • ts 1.JPG
    ts 1.JPG
    40.8 KB · Views: 26
  • ts 2.JPG
    ts 2.JPG
    41 KB · Views: 26
  • ts 3.JPG
    ts 3.JPG
    24.4 KB · Views: 26
  • ts 4.JPG
    ts 4.JPG
    41.4 KB · Views: 26
  • ts 5.JPG
    ts 5.JPG
    38.6 KB · Views: 26
  • ts 6.JPG
    ts 6.JPG
    32.8 KB · Views: 26
  • ts7.JPG
    ts7.JPG
    11.2 KB · Views: 26
  • prompt.JPG
    prompt.JPG
    14.6 KB · Views: 26

My Computer My Computer

At a glance

Windows 7 Pro 32/64 bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell 64bit desktop, HP 32 bit laptop
OS
Windows 7 Pro 32/64 bit
Why give it a .Bat extension that's old MS-DOS running command.com give it a . CMD extension. The problem will be on the user you have set and file location of desktop as that has permission set. Copy file outside user folder if that doesn't work change user run as system if you can
 

My Computer My Computer

At a glance

win 8 32 bit
Computer type
PC/Desktop
OS
win 8 32 bit
Why give it a .Bat extension that's old MS-DOS running command.com give it a . CMD extension.

The only difference between these two are the errorlevel setting and I am no checking for that.


The problem will be on the user you have set and file location of desktop as that has permission set. Copy file outside user folder if that doesn't work change user run as system if you can

Sorry don't understand that at all.
But the scheduler claims it completed successfully, so why would any of it matter.
 

My Computer My Computer

At a glance

Windows 7 Pro 32/64 bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell 64bit desktop, HP 32 bit laptop
OS
Windows 7 Pro 32/64 bit
Task scheduler result actually only reports the errorlevel of the program it invokes, but it doesn't knows what it actually does or if it really succeeded. So for correctly reporting success/failure, you must return the proper errorlevel from the bat file.

The script itself also contains two bugs.
You're redirecting all output to "tracelog.txt". That implies that the file will be created in the current directory, but the bat file does't sets it, so the file will be created in whatever folder task scheduler will decide to run it by default (it isn't guaranteed to be the bat file folder if you don't set the "start in" option). Specify the full path in the redirection command or issue a CD command before.
A second problem is that you're not checking errorlevel after the tracert commands. If either fails, the script will continue unmolested, overwriting the result with the next call. In practice what task scheduler will actually report will be the result of the last command, whose errorlevel will remain as the end result of the bat file. You should check errorlevel after each command and exit immediately with it so that the task scheduler properly reports failure when it happens.
 

My Computer My Computer

At a glance

Windows 7 Ultimate x64Intel Core i7-740QM8 GB DDR3NVIDIA GeForce 330GT
Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
As per Alejandro85 I corrected the "errors" with this script:

********
rem echo off

chdir c:\users\fred\desktop

echo. >> tracelog.txt

echo --------------------------------------------------------- >> tracelog.txt

echo Date: %date% Time: %time% >> tracelog.txt

echo --------------------------------------------------------- >> tracelog.txt

echo on
tracert -4 207.118.111.181 >> tracelog.txt
if errorlevel 1 goto errorexit1

tracert -4 lax.testmy.net >> tracelog.txt
if errorlevel 1 goto errorexit2
exit

:errorexit1
echo first tracert broken
exit

:errorexit2
echo second tracert broken
exit
*****************

But when trying to create the task I was hit with the attached error message at the very end since mine is not a "Basic Task".

I do not use passwords, so that might be why it is failing to output anything. Anybody concur?

As usual MS has hamstrung the program.

Thanks, Fred
 

Attachments

  • password error.JPG
    password error.JPG
    19.7 KB · Views: 18

My Computer My Computer

At a glance

Windows 7 Pro 32/64 bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell 64bit desktop, HP 32 bit laptop
OS
Windows 7 Pro 32/64 bit
Did you run from a folder outside users restricted folder change the user to a group like user or admin group as per post 2
 

My Computer My Computer

At a glance

win 8 32 bit
Computer type
PC/Desktop
OS
win 8 32 bit
Just realized I should use a "Pause" on my error exits to keep the window open.
 

My Computer My Computer

At a glance

Windows 7 Pro 32/64 bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell 64bit desktop, HP 32 bit laptop
OS
Windows 7 Pro 32/64 bit
Did you run from a folder outside users restricted folder change the user to a group like user or admin group as per post 2

Please go back and read Post #5, I think no password is my problem.

I am the only user, I am an administrator, I am running from c:\users\fred\desktop.

Thanks, Fred
 

My Computer My Computer

At a glance

Windows 7 Pro 32/64 bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell 64bit desktop, HP 32 bit laptop
OS
Windows 7 Pro 32/64 bit
FredY42, yes, you must give your account a password, and the credentials you specify must be of user “fred” if you’re going to write to “c:\users\fred\desktop”. Along with all of Alejandro85’s suggestions and tips, you should be good after that.


Why give it a .Bat extension that's old MS-DOS running command.com give it a . CMD extension.
Samuria, you’ve been consistently making this suggestion for a while now and I encourage you to stop. No file extension has been associated with command.com since Vista. The .bat and .cmd extensions are both associated with cmd.exe, but there are still minor differences in the way scripts behave between the two. Changing an extension from .bat to .cmd can be a breaking change.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Now I understand

MS in their infinite stupidity demands a password if you want to schedule a task easily.

Two work a rounds:
1. Create 24 Basic Tasks, that don't require a password. Took time, but that is what I did, it works.
2. Didn't find this till I was done:
Using Windows Task Scheduler with blank password
http://web.synametrics.com/syncrifytaskwopwd.htm
Didn't try it either.

It is understood and solved.
Thanks everybody
 
Last edited:

My Computer My Computer

At a glance

Windows 7 Pro 32/64 bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell 64bit desktop, HP 32 bit laptop
OS
Windows 7 Pro 32/64 bit
Back
Top