Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Task Scheduler claims succesful, but is not

23 Apr 2017   #1
FredY42

Windows 7 Pro 32/64 bit
 
 
Task Scheduler claims succesful, but is not

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




Attached Images
Task Scheduler claims succesful, but is not-ts-1.jpg Task Scheduler claims succesful, but is not-ts-2.jpg Task Scheduler claims succesful, but is not-ts-3.jpg Task Scheduler claims succesful, but is not-ts-4.jpg Task Scheduler claims succesful, but is not-ts-5.jpg Task Scheduler claims succesful, but is not-ts-6.jpg Task Scheduler claims succesful, but is not-ts7.jpg Task Scheduler claims succesful, but is not-prompt.jpg 
My System SpecsSystem Spec
.
23 Apr 2017   #2
samuria

win 8 32 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 System SpecsSystem Spec
23 Apr 2017   #3
FredY42

Windows 7 Pro 32/64 bit
 
 

Quote   Quote: Originally Posted by samuria View Post
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.


Quote   Quote: Originally Posted by samuria View Post
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 System SpecsSystem Spec
.

23 Apr 2017   #4
Alejandro85

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
23 Apr 2017   #5
FredY42

Windows 7 Pro 32/64 bit
 
 

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


Attached Images
Task Scheduler claims succesful, but is not-password-error.jpg 
My System SpecsSystem Spec
23 Apr 2017   #6
samuria

win 8 32 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 System SpecsSystem Spec
23 Apr 2017   #7
FredY42

Windows 7 Pro 32/64 bit
 
 

Just realized I should use a "Pause" on my error exits to keep the window open.
My System SpecsSystem Spec
23 Apr 2017   #8
FredY42

Windows 7 Pro 32/64 bit
 
 

Quote   Quote: Originally Posted by samuria View Post
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 System SpecsSystem Spec
24 Apr 2017   #9
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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.


Quote   Quote: Originally Posted by samuria View Post
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 System SpecsSystem Spec
27 Apr 2017   #10
FredY42

Windows 7 Pro 32/64 bit
 
 
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
My System SpecsSystem Spec
Reply

 Task Scheduler claims succesful, but is not




Thread Tools




Similar help and support threads
Thread Forum
Need help creating a task scheduler task to move files over a network.
Hello everyone, I need to have a task run that will move the contents of a folder from one computer to another over my home LAN. Files get downloaded during the night on one computer and then need to be transfered to another. Usually I am doing this by hand, but then though maybe I could get...
General Discussion
Task Scheduler - Create Task to Display a Message Reminder
How to Display a Message Reminder in Windows with Task Scheduler This will show you how to create yourself, or another user or group, a message reminder scheduled to display for when and how often you like in Windows 7 or Vista using Task Scheduler. All users on the computer will be able to...
Tutorials
Task Scheduler : Create Shut Down PC Automatically Task
How to Create a Task that will Shut Down the PC Automatically This will show a very easy way to create a task in the Task Scheduler that will shut down the PC whenever you like. This will work for Windows 7 and Windows Vista. Let's get started! 1) In the Windows start menu search box type...
Tutorials
Task scheduler unable to load task status/active tasks at startup.
My task manager is unable to load task status/active tasks at startup. I get the message: "The selected task "{0}" no longer exists. To see the current tasks, click Refresh." When I refresh I get the same message. I checked and found that under Microsoft the problem was in the defrag...
Performance & Maintenance
Task Scheduler failing to start task with merged network locations
I have two routers I usually connect to (work and home) and each have wireless access. That means there are essentially 4 network locations I have listed. I have merged each respective network location (wired and wireless) into their own singular network location - "Work" and "Home". I also...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 00:08.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App