Scheduled task won't run .bat file
Hi. On Windows Server 2008 I have a scheduled task that calls a .bat file. The fist step in the .bat file is write to a log file to the same directory in which the .bat file exists. This allows me to find out if it is ever run. When the .bat file is run from a command prompt it runs as expected writing to the log file and completing its actions. My problem is that when I run the scheduled task manually or allow it to run when scheduled it appears to run but the .bat file is never run. No log file is ever created. The History tab in the properties of the scheduled tasks shows the task being started and running then completing with an operation code of 2. I've disabled the UAC for the user account. I've set the task to run as the Administrator user and verified the permissions for that user. I know the password is correct for the task because I can make changes to the properties and save those changes with the username/password. I'm at a loss for further troubleshooting steps. Can anyone point me in the right direction to figure out why these .bat files are not being run?
September 19th, 2008 6:05pm

Hi,

As you mentioned you could not even run the program manually, I believe the cause is on the program side. Please check this program to make sure it can be run properly on the system manually.

For more information about Task Scheduler, please refer to the following article:

Troubleshooting Task Scheduler

http://technet.microsoft.com/en-us/library/cc721846.aspx

Hope it helps.

Tim Quan - MSFT

Free Windows Admin Tool Kit Click here and download it now
September 22nd, 2008 6:54am

You misread his question. He DID run the bat file manually and it works fine. When he "Forces" task manager to run the task it doesnt run it or when it kicks off automatically according to the schedule it doesn't run the bat file. THe bat file is fine. I have the same problem and it sucks.
  • Proposed as answer by Hgoossens Friday, June 03, 2011 1:42 PM
July 9th, 2009 11:17am

http://support.microsoft.com/kb/951246
see if the bat file uses quotes
mine does so scheduled task doesn't work but will run manually
there is a hotfix for this but it only lists Vista 64-bit
we're using Windows Server 2008 64-bit SP1
I don't know if the hotfix is reliable for us
searches don't find me that answer
so I'm not installing the hotfix
if you see that the hotfix is ok / reliable for Windows Server please reply
else we'll be waiting for SP2

  • Proposed as answer by switch4 Wednesday, July 20, 2011 8:01 PM
Free Windows Admin Tool Kit Click here and download it now
July 17th, 2009 1:38pm

I am experiencing the same issue on windows server 2008 64-bit. When I run the bat manually, it runs fine.
Also, this bat used to run on windows server 2003-32-bit. However, when I run the bat in the schedule task, it appears to run, but it is not working.
August 13th, 2009 8:02pm

Hi,
I think its because you need to fill in the "Start In (Optional)" field. There you need to enter the path of .BAT file! Go to your task's properties, Actions, Edit and you will find it.
Try it!
  • Proposed as answer by branfarm Tuesday, April 20, 2010 2:57 PM
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2009 2:40pm

Hello,

I have a similar problem on my Windows 2008 64 bit server: my .BAT file runs fine in a command window. But the Task Scheduler cannot execute it with expected results, with a result code of "2". And I did set the "Start In" field to the path of the .BAT file, but that doesn't solve the problem.

Any other ideas on ways around this problem?

August 19th, 2009 10:07pm

I found that the task scheduler executes the .bat file successfully when the task is set to "run only when the user is logged on" But we need it to run when there is no logged-on user. When we set the task to "run whether user is logged on or not" then the problem occurs.

I tried to reduce the commands in the .bat file to see if there are one or more commands causing the problem, but it seems that no .bat will ever run successfully when the task is set to "run whether the user is logged on or not" And the .bat files always complete successfully when set to "run only when the user is logged on" and the user is actually logged on.

Any other ideas on ways around this problem?
  • Proposed as answer by MikeG62 Friday, August 28, 2009 7:56 PM
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2009 5:21pm

Sorry, Hit the wrong button on Brian V. Do this. Setup your task under your administrator or domain admin account. This is the silly part. THEN, go the folder with the batch file (mine is simply called batch) and ADD the administrator permissions to full for the folder and each of the batch files. If the batch files have to write some data, then the target for the task ALSO should have explicit full permissions. Now try to run the task from the Task Scheduler. I got this to work MOST of the time. Gotto luv Microsoft!!!
  • Proposed as answer by MikeG62 Friday, August 28, 2009 8:05 PM
August 28th, 2009 8:02pm

Thanks for the response

It was apparently a permissions issue. The final change I made to resolve the issue was assigning the "Full Control" permission explicitly to .bat file for the account running the task. I thought that the full-control would have been inherited because of other settings that were there, but inheritance apparently didn't work. But its working now, so thanks!


Free Windows Admin Tool Kit Click here and download it now
August 31st, 2009 5:18pm

Ive still got the same issue. SBS 08.Batch filewill run if executed manually. Windows scheduled task will run if if "Run only when user is logged on" is selected. Have gone over all ideas above and double checked Admin has full permissions to batch files and all related folders, and that is the same domain admin that is scheduling the tasks. And whats with the MMC snapins crashing all the time on a brand new load with all updates?? 08 is horribly like vista, way to clunky for a Server OS...
  • Proposed as answer by Brian Vandemark Wednesday, September 02, 2009 9:35 PM
September 2nd, 2009 5:25am

I wanted to summarize all of the steps I performed to solve my problem. I would guess that maybe some of these are not needed, but I'll list them all to hopefully help you get it working

1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
2) Make sure that the task is set to "start in" the folder that contains the batch file: open the task properties, click on the "actions" tab, click on the action and then the "edit" button at the bottom. In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things: The .bat file itself, the folder containing the .bat file, and the target files/folders that are affected by the .bat script. Inherited permissions didn't seem to work for me.
4) Make sure that the account running the task is a member of the local "administrators" group for this machine
5) Make sure that the task is set to "run whether logged on or not"
6) The Task should run successfully with expected output when you right-click on the task and select "run" If it does that then it will run successfully when you are logged off.

Good Luck!
  • Proposed as answer by Brian Vandemark Wednesday, September 02, 2009 9:36 PM
Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2009 9:36pm

I had a problem with security account settings whitch did not allow the task to run.
September 10th, 2009 6:57pm

I wanted to summarize all of the steps I performed to solve my problem.  I would guess that maybe some of these are not needed, but I'll list them all to hopefully help you get it working

1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
2) Make sure that the task is set to "start in" the folder that contains the batch file: open the task properties, click on the "actions" tab, click on the action and then the "edit" button at the bottom.  In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things:  The .bat file itself,  the folder containing the .bat file, and the target files/folders that are affected by the .bat script.  Inherited permissions didn't seem to work for me.
4) Make sure that the account running the task is a member of the local "administrators" group for this machine
5) Make sure that the task is set to "run whether logged on or not"
6) The Task should run successfully with expected output when you right-click on the task and select "run"  If it does that then it will run successfully when you are logged off.

Good Luck!

#2 seems to have fixed it for me -- I already had everything else setup as noted.  Thank you very much.
  • Proposed as answer by Arvainium Tuesday, September 11, 2012 4:18 PM
Free Windows Admin Tool Kit Click here and download it now
October 14th, 2009 4:20pm

Thanks a lot! That did it! Kind of surprising since you browse (and find) the batchjob when creating the task, but I guess Microsoft had to tease us a little bit to get us to read some 2008-stuff instead of just having the answer from earlier knowledge :o)
November 25th, 2009 8:06pm

I battled this problem for a few days, trying to figure out exactly what was going on. I tried all of the steps listed in this post, however, what finally fixed my problem was taking out a simple line in the .bat file "copy G:\*.bak c:\".

the G:\ was a mapped drive.

testing this out, i did a simple .bat file, and it ran just fine through Task Scheduler. Then I tried to call my previous .bat file from the new.bat, and it would start saying it ran successfully again without ever running.
Free Windows Admin Tool Kit Click here and download it now
December 11th, 2009 4:00pm

My problem is I have a batch file that I used for years on an XP box that does Xcopy to back up files
When I run it manually I get the black command box when I schedule it or click run in the scheduler 
cmd.exe shows up in the task manager but never on the screen? So I cant tell if it is actually working or not

This is the original batch file
c:
cd \
xcopy c:\unique\*.* \\unique5\backup\tuesday\unique\*.* /s /e/v /y
xcopy c:\quickenw\*.* \\unique5\backup\tuesday\quickenw\*.* /s /e/v /y
xcopy "c:\excel documents\*.*" "\\unique5\backup\tuesday\excel documents\*.*" /s /e/v /y
xcopy "c:\word documents\*.*" "\\unique5\backup\tuesday\word documents\*.*" /s /e/v /y
xcopy c:\rma\*.* \\unique5\backup\tuesday\rma\*.* /s /e/v /y

pause

I tired

dir
pause

that works from the scheduler

I tried

xcopy c:\unique\*.* \\unique5\backup\tuesday\unique\*.* /s /e/v /y
pause

It does not work

HELPPPPPP please

January 8th, 2010 3:19pm

unsure what is going on for you, i tried doing your bat file:

xcopy c:\unique\*.* \\unique5\backup\tuesday\unique\*.* /s /e/v /y
pause

and it worked just fine.  try creating a new folder c:\unique2 and run a bat file "xcopy c:\unique\*.* c:\unique2\*.* /s /e/v /y".  If that works, then its something to do with the way you have your network share link.  What I had to do for mine was to use the IP address, but it looks like yours worked just fine on my machine using a machine name.  I would just play around with where you are copying to, see if there is a way for the name to be put in the bat that Task Scheduler will like.
  • Proposed as answer by MichaelRychter Saturday, January 25, 2014 4:25 AM
Free Windows Admin Tool Kit Click here and download it now
January 8th, 2010 9:31pm

Adding a "Start in" (Optional) path to my Task Sceduledr fixed my current problem.

Just like to offer a had a similar problem where adding the user to "log on as batch job" in gpedit.msc fixed a Tasks scheduled to run witouth the user being logged into a session (console or TS).

Local Computer Policy
Computer Configuration
Windows Settings
Security Settings
Local Polices
User Rights Assignment

May help someone in this similar Boat :)
  • Proposed as answer by Krookz Friday, August 05, 2011 5:38 PM
February 1st, 2010 2:14pm

yes, just put Start in..resolve the problem. Please make sure that put the directory of Batch files mean if the batch file was under c:\pwdscripts\batch.bat then in Start in just put c:\pwdscripts.

This happen to me since i'm not read step by step carefully, on start in i put as c:\pwdscripts\batch.bat.

Now the problem is solve...thank Brian V
Free Windows Admin Tool Kit Click here and download it now
February 2nd, 2010 6:21am

In my case, I was trying to launch a bat file on a network drive (W: in my case), but using another account as the logon.  Evidently the logon account didn't have the same drive mappings I had, so I added...

NET USE W: /DELETE
NET USE W: \\myserver\myfolder /PERSISTENT:YES

...to the start of the script and referred to the script via UNC.  It ran correctly then from forced task initiation.
  • Proposed as answer by ScottS002 Tuesday, June 07, 2011 6:41 PM
February 2nd, 2010 9:02pm

I have tried everything in this post and still can not get the tasks to run the batch with run with user logged out is checked.  This is a batch file /task that ran just fine for 5 months until mid December.
Free Windows Admin Tool Kit Click here and download it now
February 18th, 2010 6:49pm

if you are accessing a network location via a mapped drive, try using the IP address instead.  After following all of the suggestions in this thread, that solved the problem for me. 
March 3rd, 2010 4:42pm

I had trouble using this when the source was local and the destination was a network drive. To get it working I had to map the network drive in the bat file specifying the user credetitals for the destination.

This is what finally worked for me after following all of the steps above...

1. NET USE W: /DELETE
NET USE W: \\<Destination IPAddress>\<Share> <Password> /USER:WORKGROUP\<username> /PERSISTENT:YES


MOVE \\<SourceServer>\<Share>\*.* W:

2. After this the task failed to start, so I changed the option in the setting "If the task is already running, then the following rule applies: 'Stop the existing instance'.

All solved....

 

  • Proposed as answer by TyNavarre Thursday, May 07, 2015 7:51 PM
Free Windows Admin Tool Kit Click here and download it now
March 25th, 2010 1:31pm

This also did the trick for me

 

WIndows Server 2003, x64

The task ran fine when I launched it manually via Task Scheduler - Right click - Run. But when the time passed that it was due no sign of it running and time updated to show next time due but time last ran did not change. 

Updated the "start in" location and it now works fine so thanks for the info.

 

Andy

 

April 7th, 2010 11:17am

By giving the optional start in parameter, works for me .. Thanks a ton !! :)
Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2010 1:56am

I've tried alot of method in win 2008 R2 but i still can't do the task scheduler in log off so i decided to run when user is log on and i lock the computer instead of log off and that works perfectly for me.
  • Proposed as answer by Jeremy Legend Monday, April 26, 2010 6:48 AM
April 26th, 2010 1:47am

Updating start in optional parameter with "directory path" of the executable worked for me. Thanks to all.
Free Windows Admin Tool Kit Click here and download it now
April 26th, 2010 8:10am

#2 Work for me Thanks a lot!!!
May 3rd, 2010 6:22pm

I have tried everything in this post and more to get the Task Scheduler to run a .vbs script file that runs perfectly when double-clicking it.  I absolutely cannot get the vbscript to run.  The script is a simple FTP script that opens a connection to an FTP site, downloads the daily file, archives it locally, then uploads it to a different site.  I've tried calling it in a batch file, calling wscript filename.vbs, calling cscript filename.vbs, setting the working folder, using double-quotes, not using double-quotes, checking folder permissions, using the SYSTEM account, etc., etc.  You name it - NOTHING has worked.  I'm using the administrator account of the server to run the task with "run whether logged in or not" checked. 

I've spent an absolutely ridiculous amount of time trying to research/troubleshoot this.  What could I possibly be missing here?

Free Windows Admin Tool Kit Click here and download it now
May 4th, 2010 6:00pm

Make sure the Start In optional parameter hasn't got quotes around it.  I had spaces in my path, so put quotes round it, and the task wouldn't run.  As soon as I took them out, the task ran ok...
May 6th, 2010 11:00am

No quotes around the Start In param.  I have the following config on the Action screen:

  • Program/Script:  D:\Folder\Sfolder1\Sfolder2\file_name.vbs
  • Start In:  D:\Folder\Sfolder1\Sfolder2
    (Note:  No backslash on the end of the start in path - however, I've tried it both ways)

On the "General" tab, I have:

  • Run whether user is logged in or not = True
  • Run with highest privelges = True
  • When running the task, use the following user accounts:   machine\Administrator
    (Note:  I've tried "System" user here as well - no dice)

I've checked permissions for all folders, the script itself, the FTP engine folder and executable - all is well.  This thing just kicks-off and runs until the time-out period has expired.  I broke the script down to a single line and can't even get the first line to run via task scheduler (verified by putting a message box in the script as line1).

I believe it to be a permissions problem, but at this point I have no idea what permission to check - all appears to be OK as far as the administrator having administrator rights and "full control" of everything involved in this script.  I'm at a complete loss.  Damn, this is frustrating...

Free Windows Admin Tool Kit Click here and download it now
May 6th, 2010 11:54am

I had the same problem and this worked for me. Thanks!!
May 16th, 2010 5:51pm

There is a Way to run a Batch file without any 3rd party tools in Windows Server 2003/2008/2010  on System Start Up

Initially Place the required Batch file in a folder

1 . Open IIS (from run (type) inetmgr)

2 . Here under Default website create a Virtual Directory

3 . And point the Virtual directory location to the Folder where the batch file is available

4 . And finish the creation of the virtual directory

5 . Restart the System

 

As we know that IIS is a part of Windows Management Services , and we created Batch file in a folder which is a part of IIS , and on every system start we will have the IIS running which in turn runs the Batch file at the back end .

I hope this solution might solve many of the people requirements .

 

Free Windows Admin Tool Kit Click here and download it now
May 25th, 2010 12:37pm

Thanks it worked for me!!!
  • Proposed as answer by PCGuidance Friday, May 01, 2015 2:43 PM
May 27th, 2010 3:37pm

Usefull information, even almost a year later.  Thanks Brian.
Free Windows Admin Tool Kit Click here and download it now
May 27th, 2010 7:14pm

Hi

Maybe this is too late for this post.

I had pretty much the same problem, a bat-file that was running just fine with manually start but refused to start via a Scheduler

(on a Win2008 server)

I solved my by ticking in the "Run with highest privileges" in the scheduler.

and voila, it started..

rgds, kjell Liljegren

June 16th, 2010 3:50pm

have you tried with the "Run with highest privileges" tickbox in the scheduler?

 

I got my working with this

 

Kjell

  • Proposed as answer by Marc Novak Tuesday, May 28, 2013 2:09 PM
Free Windows Admin Tool Kit Click here and download it now
June 16th, 2010 3:52pm

This post was very helpful for me.  I had to do the same with net use.  My scenario was copy files from a local drive to a network drive which was not on the same domain.  The task would work when I was 'Run when user logged on' without using 'net use', but not when I set it up to work with 'Run when user not logged on'.

To recap:

[Task Settings]

1. General->Change User or Group-> Select user to run.

2. General->[X] Run whether user is logged in or not.

3. General->[X] Run with highest privileges.

4. Edit Action-> Program/script:  C:\path_to_batch\batch_name.  Note:  NO quotes.

5. Edit Action-> Start in (optional): C:\path_to_batch.  Note:  NO quotes.

 

[Batch Requirements]

1.  In my case, I was copying files locally to a network drive:

net use driveletter: /delete

Y

net use driveletter : \\myserver[IP Address if Static, or not on Domain]\myfolder user:domain\user password /PERSISTENT:YES

Once I was able to map to the network, I could use robocopy to copy my files.

 

Hope this helps to the debate.

 

 

 

June 24th, 2010 3:42pm

I wanted to summarize all of the steps I performed to solve my problem.  I would guess that maybe some of these are not needed, but I'll list them all to hopefully help you get it working

1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
2) Make sure that the task is set to "start in" the folder that contains the batch file: open the task properties, click on the "actions" tab, click on the action and then the "edit" button at the bottom.  In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things:  The .bat file itself,  the folder containing the .bat file, and the target files/folders that are affected by the .bat script.  Inherited permissions didn't seem to work for me.
4) Make sure that the account running the task is a member of the local "administrators" group for this machine
5) Make sure that the task is set to "run whether logged on or not"
6) The Task should run successfully with expected output when you right-click on the task and select "run"  If it does that then it will run successfully when you are logged off.

Good Luck!

Did everything mentioned before.

The only thing that worked for me:

7) Tick the box "Run with highest privileges".

 

[ ]'s

Edson

Free Windows Admin Tool Kit Click here and download it now
June 30th, 2010 1:35pm

Using Windows 2000 Server got a problem that .Bat or .Cmd won't run from the task scheduler but do run when executed directly.

 

Solution: after debugging the task scheduler running the bat with cmd /k "pattobatch\batch.bat" found that the name of the batch file was too long.

 

I made the name only 15 character long and it executed without issues.

 

Hope it helps

 

Cheers

July 1st, 2010 10:16am

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 

  • Proposed as answer by Darren Wallace Thursday, July 15, 2010 1:41 AM
Free Windows Admin Tool Kit Click here and download it now
July 7th, 2010 3:55pm

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 

Thank you!

 

I tried all other solutions and none of them worked for me unfortunately, but this one did the trick! Thanks again.

  • Proposed as answer by cosmic.cat Monday, November 28, 2011 11:28 PM
  • Unproposed as answer by cosmic.cat Thursday, March 01, 2012 8:22 PM
July 15th, 2010 1:41am

I have gone over all the stuff here and I still can't get it to work, but what irrates me most is the ridiculous amount of time wasted on something that should "just work". Why all the cloak and dagger permission ____ or paths, or run only, etc. Just run the damn thing.

I am using Windows 2003 updated with the latest patches and SP.  I simply have one line in my bat file:

E:\PHP-5.3\php.exe E:\Websites\GD\cronjobs\cron_fivemins.php

The task schedulers is set to run it every 1 minute every day forever. I have done all the suggestions in this thread that apply to me, but still nothing.

Is a MAC or Linux the answer???????  Tired of having to constanly fight with Windows to get something done.

 

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2010 7:39pm

I have this problem, but check this out.............

The batch file works fine when I run it manually.  When I try to run in task scheduler, it "apparently" opens the batch file but doesn't perform the actions UNTIL it gets to the line that calls another batch file, which it does and that batch file runs fine.  Now, in the batch file I'm encrypting a file then kicking off an FTP session and calling a text file that has all of the login info and the "put" command in it, then kicking off the second batch file that deletes the files (original and encrypted) from the directory.  I've tried all of the steps above (including all permission fixes) to resolve this, but no luck.  It's running on Win 2003 server with all SP/updates.  The funny thing is that I just moved all of this from a server with exactly the same setup where it ran fine.

Here's what the batch flie looks like:


pgp +FORCE -e D:\FTP\Accounting\<file_name> PRIVATEKEY
echo Start of download>bank_ftp.log
ftp -s:bank_ftp.txt trans.ourbank.com>>bank_ftp.log
echo End of download>>bank_ftp.log
REM start Delete_used_Files.bat

Any new ideas?

THanks!

Chuck

NEW EDIT:  They actually do run fine using MY credentials, which is odd because administrator should be able to do anything on there.  Oh well, I'll just run it this way.

July 30th, 2010 1:32pm

I battled this problem for a few days, trying to figure out exactly what was going on.  I tried all of the steps listed in this post, however, what finally fixed my problem was taking out a simple line in the .bat file "copy G:\*.bak c:\".

the G:\ was a mapped drive.

testing this out, i did a simple .bat file, and it ran just fine through Task Scheduler.  Then I tried to call my previous .bat file from the new.bat, and it would start saying it ran successfully again without ever running.

See my previous post, looks like your D:\ is similar to my mapped drive issue... try doing a direct link to it using the ip or server name, think thats what i ended up having to do
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2010 2:35pm

Thanks Bnatutowa, filling in the "Start In (Optional)" field did the trick for me!
August 4th, 2010 7:40pm

I had the same problem (batch file runs file in cmd, but not in the scheduler) in SBS 2008, I filled the 'start in' folder. IT WORKED!! Thank you.
Free Windows Admin Tool Kit Click here and download it now
August 5th, 2010 11:43am

Hi,

 

I have the simillar problem, my batch file running fine on when i run it manually but failed while try to schedule in the task scheduler,setting the "Start IN" folder option fix me the proble and works like charm.

August 16th, 2010 10:17am

Not sure if I am replying to just this post or the thread as there appears to be no distinction. In any event, it is supposed to be for the entire thread.

Bottom line, there is no answer to this. Task Scheduler has not worked since Windows 98 and will likely never work. It amazes me how Microsoft can screw this up so bad, but does not surprise me.

I too have a .bat file that will not work properly. It is set to run every minute, it will run maybe once every few hours at its convenience. It is not the file as it will run, but just when Bill thinks it should run, not when it is actually set to run.

So if you think you are going to get this solved, not going to happen - it is another useless add in Windows program that does not work.

Beauford

Free Windows Admin Tool Kit Click here and download it now
August 19th, 2010 1:30pm

Thanks for the tip I seriously considered punching myself in the face repeatedly this morning trying to figure out why I couldn't run a batch file using Windows Scheduler. Deleting the 'Start In' line saved me a black eye thanks!
August 23rd, 2010 8:17pm

I second that sentiment. What a complete waste of my life too. Why's it so difficult to do something that always used to work perfectly well????!
Free Windows Admin Tool Kit Click here and download it now
September 9th, 2010 8:38am

>> Tired of having to constanly fight with Windows to get something done

Ditto

September 9th, 2010 8:42am

I upgraded to Windows 7 a couple of months ago and have been having this issue since then(the batch file runs fine when I double click it but not from Task Scheduler). After all this time, I was finally able to fix it thanks to this forum post, by filling the 'Start in Folder'. Turns out its not 'Optional' after all.. What a waste!
Free Windows Admin Tool Kit Click here and download it now
September 9th, 2010 10:01pm

Hi,

I have done below to resolve the same problem on Windows Server 2008 R2 x64.

--> Once you browse program/scripts & select any batch file, it will take the full path. exp. c:\data\test.bat. I have remove this path & entered only file name into program/script box.

--> in the Start in (optional) box, i have entered this batch file path. exp. c:\data

& now it's working file. only strange thing is on the same server i have another script files running fine without above settings. but for one batch file i have done above settings & it's running fine after that.

Dhiraj

 

October 5th, 2010 2:22pm

This is what worked for me, without a hitch. Though now it only runs when an Administrator is logged in... oh well.

 

I want to seriously injure somebody at microsoft.

 

THIS IS ____ RETARDED. YOU TOOK A FEATURE THAT WAS FUNCTIONAL IN XP AND BUTCHERED IT. SOMETHING THIS SIMPLE SHOULD BE TRIVIAL, NOT A ____ PAIN IN MY ____ REQUIRING AN IN-DEPTH INTERNET SEARCH.

 

The CAPS were necessary.

Free Windows Admin Tool Kit Click here and download it now
October 18th, 2010 2:57am

Mr. Pheterson,

I scoured the web for days. This forum solved all. Call me at 212-745-9769 or read on. 2 POSTS:

PMBrian Vandemark - Wednesday, September 02, 2009 9:36

I wanted to summarize all of the steps I performed to solve my problem. I would guess that maybe some of these are not needed, but I'll list them all to hopefully help you get it working

1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
2) Make sure that the task is set to "start in" the folder that contains the batch file: open the task properties, click on the "actions" tab, click on the action and then the "edit" button at the bottom. In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things: The .bat file itself, the folder containing the .bat file, and the target files/folders that are affected by the .bat script. Inherited permissions didn't seem to work for me.
4) Make sure that the account running the task is a member of the local "administrators" group for this machine
5) Make sure that the task is set to "run whether logged on or not"
6) The Task should run successfully with expected output when you right-click on the task and select "run" If it does that then it will run successfully when you are logged off.

Good Luck!

 

DEAR_Austin - Wednesday, July 07, 2010 3:55 PM

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

     

  • on the General tab, I clicked the Change User or Group button

     

     

  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button

     

     

  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button

     

     

  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box

     

     

  • then I clicked OK and returned to the General tab above

     

     

  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available

     

     

  • then I made sure that the Run with highest privileges was checked

     

     

  • then I clicked OK and during the next scheduled time to run ... it ran

     

Thanks to everyone who has contributed, I feel a little smarter today.

     

  • Proposed As Answer by
Darren Wallace
  • Thursday, July 15, 2010 1:41 AM

     

October 18th, 2010 4:38pm

Similar problem with Scheduled tasks on Windows Server 2008, hopefully someone will know the answer...

I have a program that creates the batch files then uses SchTasks to submit them. The tasks are basically a robocopy job moving files from one server to the next.

We use the command line as follows:

schtasks.exe /create /ru %sUser% /rp %sPass% /sc ONCE /st %sSTime% /sd "%sMonth%/%sDay%/%sYear%" /tn "%sReplName%" /tr "%sCWDir%%sBatDir%\%sReplName%.bat" /F /Z /V1

Basically we put it in as a admin user, to run in 2-3 minutes from now, and I want it to delete teh task when completed. Simple right? All of the parameters are good, our Windows Server 2003 boxes use the same command line minus the "/V1" switch.

Problem is, on Windows Server 2008 the tasks get created then start to run and disappear... if I remove the "/Z" switch then it runs as expected, but does not delete the task at end of the job, and I want it to delete on completion. We do not have the problem on Windows Server 2003.

Some of the tasks actually start and run and we can see the batch file and robocopy running on the server, but no task.

Ideas anyone?

 

 

Free Windows Admin Tool Kit Click here and download it now
October 19th, 2010 10:14pm

Thanks, It s seems to solve my problem.

Nice Post!

November 1st, 2010 4:46pm

Yeah that works, but for me i had to put a end backslash for the start in path. ie. c:\pwdscripts didnt work, but c:\pwdscripts\ did.
  • Proposed as answer by vasya1 Monday, January 10, 2011 2:20 PM
Free Windows Admin Tool Kit Click here and download it now
November 2nd, 2010 3:38pm

We were having the same issue and came across this forum. Surprisingly using the "Optional" Start In field worked. Turns out it's actually mandatory.

 

How long until this "feature" is fixed? 

November 2nd, 2010 4:56pm

Thanks for the information if i put the path in where the batch file resides, it works fine. Thanks for the information!!!
Free Windows Admin Tool Kit Click here and download it now
November 3rd, 2010 5:05pm

For all that I wrote above. It ran one night and never worked again. Anyone else?
November 5th, 2010 1:46pm

DEAR_Austin's solution finally worked for me in the end. However, You can avoid all of this mess with a free program called System Scheduler by Splinterware. I have been using it for years and I started using it because of this stupid Task Scheduler problem.

EOByte

  • Proposed as answer by slydog3333 Tuesday, April 19, 2011 3:19 AM
Free Windows Admin Tool Kit Click here and download it now
November 10th, 2010 2:46pm

I battled this problem for a few days, trying to figure out exactly what was going on.  I tried all of the steps listed in this post, however, what finally fixed my problem was taking out a simple line in the .bat file "copy G:\*.bak c:\".

the G:\ was a mapped drive.

testing this out, i did a simple .bat file, and it ran just fine through Task Scheduler.  Then I tried to call my previous .bat file from the new.bat, and it would start saying it ran successfully again without ever running.

This is what worked for me also. Thank you!!
November 17th, 2010 1:01pm

Thanks Mike your answer was perfect my problem has solved.

Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 10:19am

Tried all the approaches.

Only 2 that worked for me are:

1) Brian Vandemark post of August 27, 2009 - it's the "run only when logged on that worked"

2) DEAR_Austin post of July 07, 2010 - running as Administrator group.

Note however that Scheduler often does not reflect the latest successful run or the time it ran.

 

Great post - thanks all - thought I was so brain dead that I couldn't even get a scheduler to work.  What a PITA.

Ditto on tired of fighting MS.

December 10th, 2010 7:46am

Hi,

Thanks for the advice, I tried it and it worked for me, even although I had already specified the file path in the program/script box.

Looks like it is not an (optional) option :-)

Free Windows Admin Tool Kit Click here and download it now
December 10th, 2010 10:18am

 I try it every answer in this post and similar post, but the jobs do not run if i chose the option "Run whether user

is logged on or not " do not exist some hotfix, or update that fix this problem? because if select the option " Run

only when user is logged on" and left the user "lock" the jobs works perfectly.

Windows Server 2008 R2 x64

 

 

Thanks!

December 13th, 2010 3:38pm

Yeah that works, but for me i had to put a end backslash for the start in path. ie. c:\pwdscripts didnt work, but c:\pwdscripts\ did.
Thanks, it solved my problem.
Free Windows Admin Tool Kit Click here and download it now
January 10th, 2011 2:21pm

Awesome.  These instructions did help me.  Specifically step 2.  Placing the directory of the .cmd files.  I had to go back and insert a trailing backslash after the directory name and then it worked.  Thank you so much for all of this great information.

 

January 10th, 2011 8:38pm

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 

  

Three years after this post....unbelievable the insane-ness that must go into setting a simple task schedule batch file.

This is what worked for me as well as making sure that the permissions were set correctly and the "Start in" folder path was set.

Free Windows Admin Tool Kit Click here and download it now
January 12th, 2011 3:21pm

This fixed it.
January 18th, 2011 8:06pm

The issue of no log file has been bugging me for weeks even though the actual task runs..  Thankful to find this thread:

 

"2) Make sure that the task is set to "start in" the folder that contains the batch file: open the task properties, click on the "actions" tab, click on the action and then the "edit" button at the bottom.  In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file."

 

This is what fixed it. It is obviously a bug. The log file is defined for another folder but we needed the optional 'start in' parameter filled in to get the log to be created.

Free Windows Admin Tool Kit Click here and download it now
January 24th, 2011 7:26pm

Did yoiu read the chain of responses?

 

"2) Make sure that the task is set to "start in" the folder that contains the batch file: open the task properties, click on the "actions" tab, click on the action and then the "edit" button at the bottom.  In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file."

 

I had the same issue and setting the start in fixed it. If you have an already scheduled task... click start --> admin toos --> tasks scheduler. Now click Task Schedule Library. You should now see your task in the window on the right. Right click the job and choose properties. Click the Actions tab, and choose EDIT.

Now Set a value for  "Start in (optionaly)"  The value should be the ROOT path in which your bat\cmd\vbs etc file is stored.

  • Proposed as answer by ntschultz Friday, May 13, 2011 6:47 PM
January 26th, 2011 2:44pm

[Insert profanity and amazement here.]

The 15-character filename was the problem.

The old batch file was running properly under my XP system.  I recently moved to an XP 64-bit system, and the batch file no longer worked.  I changed everything suggested --- explicit permissions, different checkbox options.  None of those changes helped.

I shortened the filename, and it ran as scheduled.

Free Windows Admin Tool Kit Click here and download it now
January 27th, 2011 6:36pm

1. Using the local account 'Network Service' works for running our batch files as Scheduled Tasks in both Server 2008 and Server 2008 R2
January 27th, 2011 9:23pm

Hi,
I think its because you need to fill in the "Start In (Optional)" field. There you need to enter the path of .BAT file! Go to your task's properties, Actions, Edit and you will find it.
Try it!

This one worked for me! Thanks!
Free Windows Admin Tool Kit Click here and download it now
February 10th, 2011 1:30pm

This is what worked for me, without a hitch. Though now it only runs when an Administrator is logged in... oh well.

 

I want to seriously injure somebody at microsoft.

 

THIS IS ____ RETARDED. YOU TOOK A FEATURE THAT WAS FUNCTIONAL IN XP AND BUTCHERED IT. SOMETHING THIS SIMPLE SHOULD BE TRIVIAL, NOT A ____ PAIN IN MY ____ REQUIRING AN IN-DEPTH INTERNET SEARCH.

 

The CAPS were necessary.

It's absolutely unbelievable how a simple task as setting up a scheduled task took me almost two hours. I am Enterprise Administrator, therefore also Domain Administrator, which also makes me one of the local administrators of the machine involved. Nevertheless all of my attempts to create an *SELFCENSORED* scheduled task failed. This is absolutely ridiculous.

As a Unix administrator it takes me like 2 minutes to create a cronjob (this includes login in, firing up the editor and hack the single command line).

It was DEAR_Austin's hint that finally solved the problem (running my scheduled task as BUILTIN\Administrators). HOW SICK IS THAT?? It's absolutely outragous that an administrator can't administer a machine.

 

Mr.Pheterson, I feel exactly the same as you did.

 

February 21st, 2011 9:59am

I ran into similar problem in Win 7 Pro.

The only way to go around it is to set the option "Run only when user is logged on". If I set "Run whether user is logged on or not", the task scheduler history showed that the event did run, but the bat file actually did not. I got the same if manually run the event from the task scheduler. It showed that the event is running, but nothing happened.

I set the event as the workstation administrator.

The result operation code is always 2, which I have no idea what it means.

"Action - Start In" property did not seem to matter in my case.

Seaport

 

  • Proposed as answer by Schwagro Thursday, March 03, 2011 6:50 PM
Free Windows Admin Tool Kit Click here and download it now
February 28th, 2011 7:19pm

I tried EVERYTHING, and this was the only thing that fixed it.  THANK YOU!!!!!!!
March 3rd, 2011 5:05pm

thanks. i also cound not get to work trying to copy from a mapped drive to a local drive. tried everything in the posts. finaly got it to run  with Run wether use is logged on or not checked by puting a NET USE P:\\00.00.00.00\<FOLDER NAME> statement in my bat file and doing a copy using the XCOPY p:\*.* D:\INPUT\*.PRT /Y/R. Note: my helpdesk ticket has 15:09:03 logged in on this issue.

m

m

Free Windows Admin Tool Kit Click here and download it now
March 3rd, 2011 6:02pm

Folks, not sure if this has been posted as this a pretty long chain, but

Suddenly, today my task (which has been running for months without fail) failed. The task scheduler reported the task as complete but nothing happened i.e. it didnt run the batch file.

Please note that i am running the file as {x} logged on or not. I didnt have highest privileges set nor did I set the "start in" path under actions.

What i had:                   xcopy \test X:  /v /y

a very simple line that copies files in the local \test folder to the X:

What i changed:  first of all I didnt change anything in task scheduler, i changed the batch file to

copy C:\test \\00.00.00.00\<folder_path>  /v /y

worked like a charm, hope this helps - worked on it all day very maddening!

March 3rd, 2011 10:27pm

Hello, and thanks everyone for all the help. I have a problem that I haven't seen anyone else having. I got the scheduled task to run sort of... I want the task to run while I'm disconnected from the Remote Desktop session, but it seems to be running right when I connect. The program sends an email, and if the task is scheduled at 8:30 and I connect at 8:45, I'll get the email shortly thereafter (8:45). Anyone have any idea as to why the program would wait to run until I connect? It does have a UI, and saw some posts about programs having problems running because it's in Non-Interactive User mode.

Anyone have any suggestions or ideas? Help is much appreciated.

Free Windows Admin Tool Kit Click here and download it now
March 4th, 2011 3:49pm

I realize this is an old thread, but thought I'd share another option to the netuse solution.  If your permissions, task properties, etc are all in order and the job seems to run differently when launched manually, manually as administrator and when scheduled with elevated privileges, give this a shot.  For me, and it appears for a few others, the issue is one of using relative vs. absolute paths.  Relative pathing is typically a big no-no for windows batch files and scheduled tasks.  I have customers for whom I host scheduled jobs using their batch files in a shared environment and for testing and portability purposes, it's often helpful to use relative paths (the customer is only aware of their network share, not the full UNC path).  My desire is for the default start path for cmd.exe to always reflect the directory where the customer's code resides.  Depending on how the task is executed (as admin, svc account, etc) the start directory can be sys32 or the users\current_user path.  Most of the customer tasks are on drives other than c:\

The solution at which I arrived was to set the start directory using cd /d %0\.. to begin my batch files where /d allows the path to traverse drives on the system, %0 returns the entire path of the batch or cmd file (including the name of the file) and \.. drops the name of the batch file from the path.  This sets the default start directory as the "home" of the batch file every time regardless of the location of the job (fixed, removable storage, etc).

March 18th, 2011 4:47pm



Mr. Pheterson,

I scoured the web for days. This forum solved all. Call me at 212-745-9769 or read on. 2 POSTS:

PMBrian Vandemark - Wednesday, September 02, 2009 9:36

I wanted to summarize all of the steps I performed to solve my problem. I would guess that maybe some of these are not needed, but I'll list them all to hopefully help you get it working

1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
2) Make sure that the task is set to "start in" the folder that contains the batch file: open the task properties, click on the "actions" tab, click on the action and then the "edit" button at the bottom. In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things: The .bat file itself, the folder containing the .bat file, and the target files/folders that are affected by the .bat script. Inherited permissions didn't seem to work for me.
4) Make sure that the account running the task is a member of the local "administrators" group for this machine
5) Make sure that the task is set to "run whether logged on or not"
6) The Task should run successfully with expected output when you right-click on the task and select "run" If it does that then it will run successfully when you are logged off.

Good Luck!

 

 

 

DEAR_Austin - Wednesday, July 07, 2010 3:55 PM

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

     

  • on the General tab, I clicked the Change User or Group button

     

     

  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button

     

     

  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button

     

     

  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box

     

     

  • then I clicked OK and returned to the General tab above

     

     

  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available

     

     

  • then I made sure that the Run with highest privileges was checked

     

     

  • then I clicked OK and during the next scheduled time to run ... it ran

     

Thanks to everyone who has contributed, I feel a little smarter today.

     

  • Proposed As Answer by
Darren Wallace  
  • Thursday, July 15, 2010 1:41 AM

     

  •  

Thanks this solved my problem, had an issue with a powershell script that used robocopy to copy files between shares (non-domain servers and "open" shares). Running the task with servername\administrator didn't work, audited the the remote machine and got logon failures etc... switched the job to run as servername\administrators and it worked!!!

Can anyone from MS explain what difference is running a job as an administrator and running as a the group administrators?

 

Br,

Eric Jagaeus

Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 11:30am

Hi Andy,

This worked for me here. I followed all the above steps and then used this NET USE command in my batch file. Immediately it worked! I really appreciate your help.

Thanks again!

 

April 15th, 2011 9:36pm

Thank goodness for this post. By adding and ending backslash to the "start in" directory, my .bat file started working using domain creds:

From this: "c:\Documents and Settings\Administrator\Desktop"

to this: "c:\Documents and Settings\Administrator\Desktop\"

Man what a waste of time

Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 4:44pm

You can avoid all of this mess with a free program called System Scheduler by Splinterware. I have been using it for years and I started using it because of this stupid Task Scheduler problem.


This is the most helpful post on this whole page.  This free program worked on the first try, no monkeying around. 

I just hate that I wasted 3hrs on Windows Task Scheduler.

April 19th, 2011 3:22am

The .bat file is not the problem at all in my case, and I don't want 3rd party software unless i write it myself.

I used "Create a basic task" in task scheduler to display a simple message box to test the scheduler since I could not get it to run my batch file. The only way the basic task would run (either when triggered or when "run" is clicked in the scheduler), is when it is set to "run only when user is logged on".

If I select "run when user is logged on or not" it will NOT run, even with both "do not store password" and "run with highest priveleges" checked, nor running as an administor.

Obviously there is no 'Start in' path to put anywhere since this is a standard system message box which is being called up, and the default 'start in' set by the basic task cannot be changed.

Setting the configuration for Windows 7 or wiindows vista makes no difference - they're both flawed.

I have not seen a fix yet, in this very long thread, which will work for a simple message box.  But I still hope....

Free Windows Admin Tool Kit Click here and download it now
April 25th, 2011 5:08pm

Thanks for this thread

 

My problem was two of the elements

 

1. No "Start In" set

2. Mapped drive in the batch file

 

1 is easy to solve, and solved 2 by using UNC path to server

 

 Regards

 

May 5th, 2011 11:03am

Well, I've got the same problem almost everyone else has.  .bat file will not run under scheduled tasks, but it runs when executed from Explorer.  I have read and reread every single post in this thread, as well as countless other posts on countless other websites and forums, and not one has solved my issue.  I want to move a ___ing file from the server to a network folder using xcopy, but apparently this is just too complex for this new operating system.  I'm seriously ready to take this server to a field and...get creative.

I guess this post isn't so much a question as it is a big middle finger to Microsoft on this one.  POS.

Back to troubleshooting, because I have to get this working. oiasd0g9fu4gg

Free Windows Admin Tool Kit Click here and download it now
May 5th, 2011 6:04pm

This solution solved my problem.. thanks a million.
May 26th, 2011 4:15pm

As others have noted above (beginning with I_live_in_TN), the NET USE commands seem to be required in _all_ scripts that refer to a mapped drive.

They're still required on my new Windows 7 system (I had hoped they wouldn't  be any more).

Mapped drives are arguably neater than UNC references in scripts (and in Windows Explorer) for two reasons: 1) they're more compact and 2) they're constant (even when server names change).

I had hoped that the Windows 7 Task Scheduler would be improved so that it would use the drive mappings of the account that it's using. In other words, if Task Scheduler is running a script using my user account, I expect it to use my mapped drive N:. But no, it doesn't, so the script needs to map drive N: for itself.

R. Oltmanns mentions UNIX cron jobs. When you tell a cron job to run from a user account, it really does. Windows--not yet.



  • Edited by ScottS002 Tuesday, June 07, 2011 8:11 PM added context (posts aren't threaded here).
Free Windows Admin Tool Kit Click here and download it now
June 7th, 2011 7:53pm

Bummer that  you would have to put your password in a bat file (AndyMay154). Security leak.
  • Edited by ScottS002 Tuesday, June 07, 2011 8:13 PM added reference (posts aren't threaded here).
June 7th, 2011 7:57pm

That's what worked for me too. With all other options suggested here checked, a simple batch file would not  work via scheduled task. To be exact, only "copy file" line would not work, and manual execution of this line in CMD would work fine.

Fix:

modifying Change User or Group... in scheduled task Properties\General  

changed domain\administrator user to domain\Domain Admins group 

 


 

Free Windows Admin Tool Kit Click here and download it now
June 9th, 2011 10:09pm

I qwas experiencing the same issue while trying to run a batch file in a scheduled task. I was trying to run a command line for my FTP application ans eackh time is said successful with a result of 0x2. After reading multiple forums about permissions etc.. and not fixing the issue i did the following.

 

1. Log in with admin account on server.

2. Run the application(ran as different user) and make and configuration changes with the user account that will be running the scheduled task. Close the application.

3. Recreate the scheduled task using the sheduled taks account.

4. Run the scehuled task manually to check it works.

 

What I put it down to is a badly written app that needs to access data in the profile of the user the  application was installed configured under.

 

Hope this helps anyone having this issue.

June 15th, 2011 7:01am

The only way for me to solve it (since it was a copy from a network share) was to put the \\computername\share on my bat file.

i had a map network drive and it dint work.

 

Thanks

 

 

Free Windows Admin Tool Kit Click here and download it now
June 20th, 2011 2:09pm

Hi,

 

I am having a similar problem I am trying to run a batch script to backup SQL Server. The batch script runs fine if I run it manually but If I try to run it though task schedular I get the following error:

 

C:\Windows\system32>.\ExpressMaint2008.exe -S Lee\Arch -U sa -P SQL123fidd -D AL
L_USER -T DB -B "G:\Database Backups\Arch" -R "G:\Database Backups\Arch"-BU DAYS
 -BV 2 -RU WEEKS -RV 2 -C -BF $(DATE)_$(DB)
'.\ExpressMaint2008.exe' is not recognized as an internal or external command,
operable program or batch file.

 

However I never get this error if the batch file runs normally.

June 27th, 2011 4:55pm

Hi there,

Actually i've just completed the same task as you. I built a script that backs up databases on MSSQL server 2005 Express and another that backs up MYSQL databases.After testing that these run in a DOS prompts (logged in under RDP) I setup a scheduled task for each. Running MS Windows Server 2008.

It sounds like you have your scripts in place etc... (but check your executable path) but I found there are two key components that need to put in place and if not done then you will experience the fault where they look like they run in Task Manager but they don't.

1. Ensure that in the General tab you choose to 'Run with the highest priviliges'.
2. Ensure that you have filled in the 'Start in (optional)' filed in the actions tabs. (this should be set to the folder where your script resides).

Ian

 

Free Windows Admin Tool Kit Click here and download it now
June 28th, 2011 12:29pm

Hi Ian,

 

I have got the Run with the highest priviliges option on and I have also set the starts in path to the path of the folder that contains the script. Also the Executables are in the same folder as the Script. I can get the script to run now but it is still giving me an error when it tries to run the executables. This error is not there when I run the script manualy.

 

Matt

June 28th, 2011 1:27pm

Hi Matt,

So are you running the 'executables' under 'Action/start a program' with switches?
or running a batch file (eg. test.bat) that includes a line that points to the executable with switches?

I had a quick dig and found this ref: seems to be relevant:

http://sqlblogcasts.com/blogs/sqldbatips/archive/2008/08/19/using-expressmaint-on-sql-server-2008.aspx

"With the release of SQL 2008 Express I thought it would be helpful to add a note that it you try to use the ExpressMaint utility to perform database maintenance operations against SQL Server 2008 on a computer which has never had SQL Server 2005 installed you will encounter an error. This is because ExpressMaint references the SQL 2005 SMO assemblies. In order for it to work correctly, simply install the SMO 2005 redistributable on the SQL Server 2008 computer and apply at least SQL 2005 Post SP2 Cumulative Update 5."

Ian

Free Windows Admin Tool Kit Click here and download it now
June 28th, 2011 1:42pm

Hi Ian,

I have managed to get the Executables to work now it was because I was using ./%Executable_Name% and it couldnt find it so I had to add the Drive and folder location so it's now "C:\Database backups\%Executable_Name%".

The Final Bit of the script should start a powershell script to rename the .bak files however when it is run through task manager it cant find the script. The powershell script is in the same folder as the batch script. I have tried the same thing as I did with the .exe files and this still didnt work.

Matt

June 28th, 2011 2:18pm

Hi Matt,

Have you tried adding a 'PATH' statement to the system config?

Ian

Free Windows Admin Tool Kit Click here and download it now
June 28th, 2011 2:26pm

Hi Ian,

 

I have figured it out now. Basically because my path had spaces in it I had to add a single quatation mark at the end of each folder name with a space in it. e.g.

C:\'Backup Scripts'\'Powershell Scripts'\PS.Ps1

 

My Backup script now works. However its a bit weird how the script worked perfectly fine before if I ran it manualy it seems task manager in server 2008 can be a bit weird at times.

 

Anyway thanks for the help

Matt

June 28th, 2011 2:52pm

Just for future reference for anyone else who has a similar problem with powershell this is the website where I found the answer.

 

http://social.technet.microsoft.com/Forums/en-US/winservermanager/thread/d47d116e-10b9-44f0-9a30-7406c86c2fbe/#a4addb3e-fdb9-4a65-84f8-7ff295efde1b

Matt

Free Windows Admin Tool Kit Click here and download it now
June 28th, 2011 2:56pm

Hi, I think its because you need to fill in the "Start In (Optional)" field. There you need to enter the path of .BAT file! Go to your task's properties, Actions, Edit and you will find it. Try it!

This proposal worked for me.

10x

June 29th, 2011 7:41pm

Thanks, all, for the great suggestions in this thread.

The solution to my problem was to use a UNC path for the 'Program/script' argument, instead of a mapped drive letter. This one change enabled my script to run successfully with the 'Run whether user is logged in or not' option.

Like many folks, I also tried using the 'Start in (optional)' argument. Contrary to most posts, I am only able to run the job *without* using this argument. I don't understand why this is the case, but I'm looking into it more now. At any rate, I mention this for people who are still stuck; it might be that the 'Start in' argument that has worked so well for so many could actually be causing the problem.

 

Lastly, I'd like to understand better whether there are other environment-type settings, beyond just mapped drive letters, that are not preserved when using the 'Run whether user is logged in or not' option. To that end:

Q: Does anyone know of a reference that explains the difference in the "session context" (I don't know the proper Windows term) between the 'Run only when user is logged on' and 'Run whether user is logged on or not' options?

 

Free Windows Admin Tool Kit Click here and download it now
June 30th, 2011 10:15pm

I've struggled with getting Task scheduler to run an executable for a couple of days and none of the solutions on this page have helped. Since this page features prominently on Google for searches relating to Task Scheduler problems I thought I would post here to suggest a workaround for this problem. I was trying to get Scheduler to run a .vsb which opened a playlist in iTunes and began playing it. No luck since the computer would wake but would stay idle at the login screen, regardless of whether I provided Scheduler with my password or not. I installed this handy application: http://www.dennisbabkin.com/php/download.php?what=WOSB You can instruct it to run any file on wakeup. It doesn't even need your credentials because it does not login to your account to run the file. Hope this helps a few people.
July 9th, 2011 5:33am

Hi!!

first, I've read all the posts here and still not found my problem

We have a task scheduled for every night at 1h00, the task launch an CMD file that is on a share (\\xxxx\dfs\xxxx)

the task is programmed for wake the computers from hibernation, the task work very well on all computers, the cmd is executer everytime(we have logs), my problem is that in the task we install a file, the file is on a share (\\xxxx\dfs\xxxx) and on some computers it seems that the dfs can't be reach and on other it work perfectly, I tried to use the server name directly, same result, some work other not

and after a couple of days the computers that doesn't work, work, I can't figure where is the problem

Free Windows Admin Tool Kit Click here and download it now
July 21st, 2011 7:48pm

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 


Thanks Dear_austin.  Your answer was the only one to fix my problem.  Now to get past the blat registry error......................
July 25th, 2011 9:14pm

Adding a "Start in" (Optional) path to my Task Sceduledr fixed my current problem.

Just like to offer a had a similar problem where adding the user to "log on as batch job" in gpedit.msc fixed a Tasks scheduled to run witouth the user being logged into a session (console or TS).

Local Computer Policy
Computer Configuration
Windows Settings
Security Settings
Local Polices
User Rights Assignment

May help someone in this similar Boat :)
That worked for me. Already had all the other stuff configured when I initially created the task. Was running them as the domains "administrator" account. As soon as I added it to login as batch job it ran successfully from the scheduler.
Free Windows Admin Tool Kit Click here and download it now
August 5th, 2011 6:01pm

I'm running W2K8-R2 - scheduling a 3 line bat file - to copy SQL backups to a NAS

net use Z: \\IP address\dir  -> robocopy local_fullpath(had to use quotes - do to "program files" and "Microsoft SQL Server"  to remote_fullpath -> exit

One system worked first try but - but another exactly the same had all the symptoms mentioned in this thread.

After doing a combination of everything mentioned - Including - full control permissions(dir and .bat file)..., start in (optional)..., security policy...,

Its was "run with highest priviledges" that did it for me....But to be honest? ... It was then that I saw an hour glass for a bit and could "feel" (yes a 30 year sys admin) that it was "setting up"  - ALMOST LIKE I managed to get the scheduler to execute the setup code in proper order.....

Wow - what a mess.... this thread helped a lot....but I don't think it will ever change status from "proposed answer" to "answered" 

Take care everyone..

August 18th, 2011 4:29pm

Using Windows 2000 Server got a problem that .Bat or .Cmd won't run from the task scheduler but do run when executed directly.

Solution: after debugging the task scheduler running the bat with cmd /k "pattobatch\batch.bat" found that the name of the batch file was too long.

I made the name only 15 character long and it executed without issues.

Hope it helps

Cheers

Yes, GardoneVT -- that did help.

I had this problem in both Server 2003 and Server 2008 (not R2) in the same day (related tasks), and LOL I did so many of the things listed in this thread... that I'm not clear WHICH ONES were critical.   But in case it helps anyone, I guess I can share the final step I took in each case...

In the case of Server 2008:
--THE LENGTH OF THE BATCH FILE NAME was critical:  when I renamed the BAT file from a 47-char name to a 30-char name, the scheduled task started working.

In the case of Server 2003: 
--ADDING THE EXECUTING USER TO THE ADMINISTRATORS GROUP was critical:  after that... working.

Note that I, too, added "Log on as a batch job" for the users.  This link helped with that, and with FINDING THE SCHEDULED TASKS LOGFILE in Server 2003: 
http://social.technet.microsoft.com/Forums/en/winservergen/thread/ca6c856e-ac17-4664-bf6f-9c9db4c3714f

Success to all...

 

Free Windows Admin Tool Kit Click here and download it now
August 26th, 2011 11:19pm

Thanks for the help!!!  After banging my head against the keyboard repeatedly, I finally sought help and your suggests resolved our issue.  Thanks again!!

 

August 29th, 2011 6:27pm

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 

Great!. This one fixed my problem. Remember to select "Administrators" Group, not Administrator user.

 

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2011 3:14am

Spent a few hours troubleshooting this and various group policy isssues that can also cause things to break ....

How could this basic functionality be so very broken on Windows 2008 R2 ? Is this seriously meant to be a modern operating system we can run business stuff on in secure ways?

. I just want to create a task to run as a low priviledge user with limited access to stuff (enough to zip up a specific file directory perhaps) and maybe copy stuff over the network to a network share that that user has only modify rights to for backups. I don't want it logged in at the time to have to kick off the batch job because I'm creating just a low priviledged account with only access to what it needs.

You're telling me I have to make it an administrator and run it with highest priviledges? What? This is stuffed!

Looks like I'll have to rewrite my scripts which have been working for about 16 years on various NT versions and could handle long file names to something with shorter filenames?? What the heck is going on with that?

It looks like the single-user desktop focus has totally killed the multi-user multi-app server administerability of Windows NT at Microsoft, and that the "improved security" is having the exact opposite effect of me having to run stuff with "full admin" rights unnecessarily.

 

September 10th, 2011 2:01pm

But thank you all - this discussion did help me through getting some batch jobs running

The fix for me was the workaround for inheritance not behaving as expected  - giving the account explicit rights on the batch file being run, as well as run with full privileges.

Its a bit annoying that the task scheduler interface doesn't help create a task and grant the appropriate privs as you configure the scheduled task. Maybe that can be improved in the next Windows version?

 

 

Free Windows Admin Tool Kit Click here and download it now
September 10th, 2011 2:38pm

I just made this script and it's worked for me

1. net use X: \\ipaddress or FQDN\\folder  password /user:domainname\userdomain  /persistent:yes

2. Execute the command that i would like to run

3. net use X: /delete

 

The reason for this simple steps is that it doesn't mean that the mapped drive is OK maybe using the command net use in command windows help you verify the mapped drive status, if it disconnect the script could give error code 0x2. You need guarantee that the mapped status is OK to get run the command in your script.

 

September 15th, 2011 8:43pm

Similar issue, Server 2008 R2 trying to run a batch file to dump a sql file to a mapped network drive. Batch file runs perfectly from command line but task would not complete successfully as scheduled.

The anwser for me was to use the local Servername\Administrators group as the controlling account. Odd since my domain admin account is already nested inside that group but trying to run with my domain admin account failed 100% of the time from within task manager. Thanks to all previous posters for sharing their (many) solutions to what should be a simple thing to achieve.

Free Windows Admin Tool Kit Click here and download it now
September 26th, 2011 2:36am

But does this work when logged off?

I have a batch file that runs a Java program that accesses a Lotus Notes ID file (I know, bad news to begin with) but it works fine from the command line. The domain admin account did not work, but running it from the Administrators group worked fine while logged in. I followed all the other steps listed in this thread, and nothing worked except this. Problem is, the task needs to run in the morning when nobody's logged in.

September 29th, 2011 8:32pm

I had a similar issue with SBS 2003.

I could manually start the scheduled task, however it would not run on it's schedule. Had already followed all the best practises, and tried several fixes from various forums with no luck. 

Turns out in my case, whilst the server is running off AC, It thinks it is running off the battery. I went into the schedule properties, navigated to the settings tab and unticked the options under power management 'Stop schedule / don't start schedule if on battery power' and it resolved my problem. Hope this helps all the other people who are still stuck.

Free Windows Admin Tool Kit Click here and download it now
October 13th, 2011 11:02pm

This solution worked beautifully!  Thank you soo much!
October 27th, 2011 4:16pm

#2 did the trick for me as well. Thanks for that.

I still wonder why MS has the (Optional) out there when it is NOT optional!


Free Windows Admin Tool Kit Click here and download it now
October 28th, 2011 3:13pm

This was implied in Brian Vandemark's Wednesday, September 02, 2009 9:36 PM reply, but written here for clarity....... The name of your batch file is the ONLY thing that should be in the Program/script line. The PATH-to-the-Batch-file is what goes into the: Start in (optional): box I had the same problem in that when I clicked on the batch file it ran beautifully and so I thought, "YES" it works....So I just put it (PATH AND ALL) in as my START PROGRAM in Task Scheduler and it failed and failed and failed ??? But when you strip off the path and put the path in the Start in box and then ONLY PUT your Batch File name in the Program box - it WORKED !!!
November 2nd, 2011 3:16pm

I picked the "Run only when user is logged on" option and it worked for me, everything in the post i tried previously did not work. So maybe this server doesnt have the hotfix.
Free Windows Admin Tool Kit Click here and download it now
November 14th, 2011 6:23pm

Yes - filename way too long for me to. Shortened it & it works a treat. All the other stuff above was red herrings, but very grateful for your input any way!
November 17th, 2011 5:34pm

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 

Thank you, thank you, Thank You! I have been dealing with this issue off and on (would throw up my hands and run my script manually) for over a month. I had tried absolutely everything in this thread and it was only running it in the Administrators group (the user I had selected was in the Administrators group, I even tried the Administrator user) that solved my problem. I would buy you a drink, if I could. :) Like others, I cannot believe that this problem has existed for so long. I understand MS's desire to created a more secure server\environment but it's ridiculous that it takes this much troubleshooting 'possible' solutions to find the right combination to get it working. Thanks all!
Free Windows Admin Tool Kit Click here and download it now
November 28th, 2011 11:35pm

I have found .bat and .cmd files do not run correctly either.

My solution:  Don't run the batch file directly.  Have TaskScheduler run:  cmd.exe with parameter:  /C YourBatchFile.bat and start in: C:\SomePath\ (without quotes!) where C:\SomePath\YourBatchFile.bat exists.  And then select the radio button for it to run regardless if you are logged in or not.

 

Exit errors may not be logged to the Event Log (they weren't when the .bat ran directly from Task Scheduler when I was logged in), so I find it best to manually log your own Event in case a error occurs and you want to send an email.

REM Logs an event which causes eventlog to send an email when it fails.  Also, "/l application" needs to be lowercase.
eventcreate /t error /id 203 /l application /d "your logged description."

And then make a completely separate task with a trigger:  On an eventBasic Selected.  Log: Application.  Source: EventCreate. Event ID: 203.  And have the action on this task send an email (attaching any generated log files, if needed).

Hopefully helpful (took me 3 days to figure all this out...gar)

  • Proposed as answer by TamusJRoyce Thursday, December 01, 2011 3:42 PM
  • Edited by TamusJRoyce Thursday, December 01, 2011 3:51 PM
December 1st, 2011 3:42pm

I got it working: Create a basic task. Don't check "open the properties dialog for this task when I click finish" Create it, but don't change it afterwards. This will work. If you want a different schedule, delete the task, create a new one. In my opinion the new scheduled tasks (Win2k8 / Win7) is worse this way.
  • Proposed as answer by Anjana_Murali Thursday, January 12, 2012 6:34 AM
Free Windows Admin Tool Kit Click here and download it now
December 8th, 2011 9:26am

I had several issues that together caused my problems: - My application needs Excel to make an export. Microsoft decided to forbid unattended use of Excel in Windows 2008 Server. - I had an UNC path in some scripts and batchfiles, now turned them to driveletters. - I used the "Run wether user is logged on or not" option and checked the option "Do not store password". At last I unchecked this box and everything works fine now.
December 12th, 2011 11:55am

I tried every single option suggested in the posts. And by everything I mean EVERYTHING. But this was the one that helped me. Use Create Basic Task instead of Create Task. And that worked!!!!!! I was trying to map to a network drive use net use commands on a win2k8 machine. Thanks for helping to get this sorted.
Free Windows Admin Tool Kit Click here and download it now
January 12th, 2012 6:36am

This fixed it for me. Thanks. :)

February 7th, 2012 5:52pm

Well, i feel a bit stupid right now but i guess i can share my little fix with you all.

I had already tried everything in here and been troubleshooting this problem after a migration from Win Server 2003 to Win Server 2008. After some 6 workhours of trying everything i could coem up with i found the solution:

1. Reboot of server.

2. Wait to be able to login.

3. Try to run task again manually. ooh, fixed! :P

DOH!

Regards,

Mikael

Free Windows Admin Tool Kit Click here and download it now
February 9th, 2012 1:42pm

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 

This was the ticket!

Beats me why this would be so stupidly complex to do such a simple task. I had (like other here) spent an enormous amount of effort attempting to get this simple batch file which calls a couple of vbs scripts to run on the Scheduler.

Methinks the Scheduler ought to be called the "sort-of-Scheduler-that-really-doesn't-work-too-well-but-we-needed-to-have-one". Sheesh. Frustrating.

February 9th, 2012 10:44pm

Yeah, thanks. I had the same issue, for the purpose of testing i had created the Task to RUN as a different User. I had to go and assign Full Control to the .BAT File and the Folder that contained my .BAT file. Works like a charm. Thanks
Free Windows Admin Tool Kit Click here and download it now
February 10th, 2012 5:07pm

I have tried "all the above" and interestingly it would not allow the administrator to be set as the running logon. However if I set the local logon to include the administrators group in its config, and then set the scheduled task to be run from the administrators group rather than the user - hey presto it works. Not nice to have spent so long trying to get this working.
February 13th, 2012 10:26am

We're having a similar issue, a task that runs fine when launched manually, but when run as a scheduled task and the user is not logged in, it fails. The Task is conigured to run when the user is not logged in, and the batch name is short. The 'user' is a service account, a member of the Adminstrators group. The .exe being launched is failing on its authentication to the SQL database. Again, this works when run manually. Why would Task Scheduler under Server 2008 fail to pass along these credentials correctly, as its configured to run using these same credentials?
Free Windows Admin Tool Kit Click here and download it now
February 14th, 2012 1:38am

Hi,
I think its because you need to fill in the "Start In (Optional)" field. There you need to enter the path of .BAT file! Go to your task's properties, Actions, Edit and you will find it.
Try it!
This worked for me.
February 14th, 2012 4:16pm

I too am still suffering this issue.  I used this batch without incident on an XP PC.  I have replaced it with a Win7 Pro workstation.  I've tried everything listed and double and triple checked every setting.  I've tried countless combinations of all of the recommendations.  I am logged in as a domain Administrator, who is added to local administrators, gave full folder access to both the domain administrators and the actual admin user, for ALL folders and files on both sides of the copy operation. My batch is c:\archives\dbackups.bat

The batch file is simply:

xcopy k: f:\dailydiff /s /y /d (K is a netowrk share (and yes I applied explicit permissions there too / and F: is a local USB drive (removable backups). 

This batch file works perfectly when double clicked or run manually via CMD window.  Following the various instructions listed throughout this article, the ONLY way the batch will kick off correctly, is when I set it to "Run only when the user is logged on".  What kills me right there is that it simply shouldn't run with one selection, yet not the other, when the actual login is NOT a factor, right?  How is this anything but a programming bug?  I wish someone at MS would listen to many of us here and actually test and try to correct it, rather than have forum gurus keep telling us we're doing it wrong...

I too, have spent WAY too much time troubleshooting this!

Free Windows Admin Tool Kit Click here and download it now
February 14th, 2012 5:28pm

kprivigyi, Yours sound way close to mine. Make sure you do the "net use k: //...." command in the .bat file as I have found it is a different session than your foreground. and set General -> whether or not..... "run with highest priviledges" Triggers -> sometimes I miss "enabled" Actions -> "Start a Program" Browse to the bat Start in (optional) = NOT OPTIONAL same a where bat file is Conditions -> I set "... only if AC..." but doesnt seem to matter Don't set "Start only if the following network connection..." Setttings -> Set "Allow task to be run on demand" Good Luck
February 14th, 2012 5:42pm

This has been a long tiresome road trying all these proposed fixes... I only have one symptom that I didn't see here that might differentiate my issue...

The task always runs and shows completed, but never -actually- runs, same as a lot of others here. But.. one thing I see is no matter what I try in this thread, the tasks's settings never keep the "run with highest privileges" box checked unless I select the entire Administrators group, BUT doing that makes the process not run when I'm not logged in as an Administrator.

Any ideas? Keep in mind I've tried every single thing on this thread.

Thanks.

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 10:30pm

I have same issue: One .bat file that run sqlcmd.exe calling an sql script .sql. Running in a command window, all work fine. Running in Scheduled Task did not run. I solved simply adding the "Start in" parameter. I want to thank you Microsoft to help us stay always under pressure to understand the "il"logical settings form on o.s. to another. Have a nice day
February 18th, 2012 2:59pm

This resolved it for me...thanks!
Free Windows Admin Tool Kit Click here and download it now
February 21st, 2012 10:44pm


Having wrestled with a similiar issue along with the System Administrator at work, he found a further fix related (at minimum) to Windows 7 permissions/rights.

How to grant "log on as batch job" in Windows 7:
http://toblogornottoblog.co.uk/blog/misc-it/1/how-to-grant--log-on-as-batch-job--in-windows-7-home-premium.php?blog=159&page=1&order=d&mode=

Cheers, Mark.

February 23rd, 2012 6:03pm

Win7BetaTesterLK,

This is the same issue that I had.  The history log would show that it ran.  My initial setup (onto a new machine, this is the second time I had to find this answer, thank goodness I replied to this thread so I could find it!) showed my task ran for about 18mins but it didn't do anything.  After tweaking it again (before finding this thread), it would show that it ran for a minute or less.  From history, I know that my script takes approx. 24hrs to run and the cmd box that would pop up on my other image wasn't pop up with the process.

Does the initial account that you are setting up the task have administrative privileges?

Free Windows Admin Tool Kit Click here and download it now
March 1st, 2012 8:14pm

I have tried all of the above to no resolution. I tested with a task with it's action being only to display a message. That simple test won't run either as administrator. The event viewer for the task scheduler says it's doing a great job though. My batch files run fine if I manually double click them.

-DTechGuy

March 9th, 2012 4:05pm

Hi - I realize this is an old thread but I didn't see this solution. The problem, I think, is that the scheduled task user doesn't have the correct rights to execute cmd.exe. This would be required to run the bat file. What I did was find cmd.exe in c:\windows\system32 and add my user with full rights to the security properties for this file. The scheduled task ran fine after that.
Free Windows Admin Tool Kit Click here and download it now
March 9th, 2012 4:15pm

...Don't run the batch file directly.  Have TaskScheduler run:  cmd.exe with parameter:  /C YourBatchFile.bat and start in: C:\SomePath\ (without quotes!) where C:\SomePath\YourBatchFile.bat exists...

Thanks TamusJRoyce! That sorted it for me.

I was having issues on an old Windows 2000 server. No idea why it wasn't allowing it to run, I've set everything else that would prevent it. But doing this as you advised worked perfectly.

I just changed the Run entry to:      C:\WINNT\System32\cmd.exe /C C:\Backup.bat    and left the "Start in" box just to C:\

(also I had to add /UM to the batch file as it wasn't able to overwrite the file, but that was a unrelated issue)

March 15th, 2012 2:08pm

So I had this problem, I double clicked on the .bat and notepad opened the .bat.  I ran through this whole long and very absorbing thread of this forum.   I wanted to save the entries that were most helpful, so I copied and pasted into a notepad document (.txt)  I could not find a way to attach it here, so I copied and pasted that below. I called it a synopsis....  Did I spell that right?

As you can see, I added my experience at the top (A and B).  The stuff I copied is noted with the original author. This is the first time I posted anything to these here microsoft forums, although I have been telling computers what to do for 40+ years.  So hope I did not break any social protocols here.

==================================== Begin ====================================
     Running A Dot Bat File in Windows Server 2008 Vista 7 etc and beyond V01
============================================================================

-----------------------------------------------------------------------------------------------------------------------------------------------------
This was created as a synopsis of the entries at the following forum location:
http://social.technet.microsoft.com/Forums/en/winservermanager/thread/d47d116e-10b9-44f0-9a30-7406c86c2fbe
-----------------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------------
A) manually
     This is an opinion added by Thomas Rock
----------------------------------------------------------------------------------------------------
    1) Open a command window (that would be cmd.exe)
    2) In the command window navigate to the directory containing the .bat file and it's dependents
           ex...  C:\Program Files (x86)\Bobs\Your\Uncle
    3) Run the .bat file by typing the name including the .bat extension (in the command window of course)
             TheBatFile.bat

       Note: Using this method, the .bat file will run in the current command window directory (the directory where the .bat file is located)
                         (this is the key for getting it to run in the task scheduler... Start in folder option)
-----------------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------------
B) The double click
            This is an opinion added by Thomas Rock
----------------------------------------------------------------------------------------------------
     1) Using Windows exlporer, find the .bat file
     2) use the mouse or other device to double click on the .bat file
     3) if it does not run (in my case the wordpad application opened the .bat file)
          a) make sure that the .bat file extension is associated with the program c:\windows\system32\cmd.exe
          b) make sure the profile you are using has rights to run the cmd.exe
          c) make sure the profile has the rights to the directories, the .bat and any other objects used or affected by the .bat file processing.
-----------------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------------
C) As a task using task scheduler
     Proposed As Answer by Brian Vandemark Wednesday, September 02, 2009 9:36 PM
----------------------------------------------------------------------------------------------------
1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
2) Make sure that the task is set to "start in" the folder that contains the batch file:
      a) open the task properties
      b) click on the "actions" tab
      c) click on the action and then the "edit" button at the bottom. 
      d) In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
      e) be sure to include an end backslash for the start in path "C:\dir1\dir2\"    (the last backslash is not optional)
3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things:
      a) the .bat file itself
      b) the folder containing the .bat file
      c) the target files/folders that are affected by the .bat script. 
           Note:  Inherited permissions did not seem to work.
4) Make sure that the account running the task is a member of the local "administrators" group for this machine
5) Make sure that the task is set to "run whether logged on or not"
6) Tick the box "Run with highest privileges".    
       Note: Point 6 here was from Edson F. Lima Wednesday June 30 2010 1:35 PM
                  The original point 6 was moved to point 7.
7) The Task should run successfully with expected output when you right-click on the task and select "run" 
        If it does that then it will run successfully when you are logged off.

-----------------------------------------------------------------------------------------------------------------------------------------------------
D) Still another way as a task using task scheduler
      Proposed As Answer byDarren Wallace Thursday, July 15, 2010 1:41 AM
----------------------------------------------------------------------------------------------------
This has been bugging me for 6 or 7 months.
I don't have admin rights to the box and the guy who does is very busy...
so I've felt the range of emotions mentioned above.
 
I tried most everything above as well. But what seemed to get my processes processing, was ...
   on the General tab, I clicked the Change User or Group button
   in Select User or Group (first smaller dialog box)  I clicked the Advanced... button
   in the next Select User or Group (second bigger dialog box) I clicked the Find Now button
   in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
   then I clicked OK and returned to the General tab above
   the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
   then I made sure that the Run with highest privileges was checked
   then I clicked OK and during the next scheduled time to run ... it ran

   Note: See note in A) Manually above.
-----------------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------------
E) Task scheduler recommendation
     Proposed As Answer byTamusJRoyceThursday, December 01, 2011 3:42 PM
----------------------------------------------------------------------------------------------------
I have found .bat and .cmd files do not run correctly either.
    My solution:  Don't run the batch file directly. 
    -----------------------------------------------------------
       Have TaskScheduler run:  cmd.exe
          with parameter:  /C YourBatchFile.bat
         and start in: C:\SomePath\ (without quotes!) where C:\SomePath\YourBatchFile.bat exists. 
        And then select the radio button for it to run regardless if you are logged in or not.
  
Exit errors may not be logged to the Event Log (they weren't when the .bat ran directly from Task Scheduler when I was logged in), so I find it best to manually log your own Event in case a error occurs and you want to send an email.
 REM Logs an event which causes eventlog to send an email when it fails.  Also, "/l application" needs to be lowercase.
eventcreate /t error /id 203 /l application /d "your logged description."
And then make a completely separate task with a trigger:  On an event.  Basic Selected.  Log: Application.  Source: EventCreate. Event ID: 203.  And have the action on this task send an email (attaching any generated log files, if needed).
 
Hopefully helpful (took me 3 days to figure all this out...gar)

-----------------------------------------------------------------------------------------------------------------------------------------------------
===================================== End ===================================
     Running A Dot Bat File in Windows Server 2008 Vista 7 etc and beyond V01
============================================================================

 
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2012 5:40pm

I tried everything else above this suggestion, and this was the first one that worked for me!  Mine is on Windows Server 2008 R2.  Thank you so much for posting!  
March 23rd, 2012 8:53pm

This simple missing step, solve my problem!

Thanks Bnatutowa!

Free Windows Admin Tool Kit Click here and download it now
March 26th, 2012 7:46am

Please do the followings.....for running .bat file in server 2008 by Task Schedular....

-- Run only when user is logged on

and the user should be of domain account....

this solved my problem.....:)


  • Proposed as answer by Jadon Thursday, March 29, 2012 4:52 AM
  • Edited by Jadon Thursday, March 29, 2012 4:53 AM new
March 29th, 2012 4:49am

HI, I've a simple batch file which calls the below vbs script to send email using MAPI. I've scheduled the batch script through windows scheduler and it's working fine when I set the task as "Run only when user is logged on". I manually run the job from task scheduler, and I get email everytime I run it. Also I'm one of the Administrators on this server. Set ol = WScript.CreateObject("Outlook.Application") Set ns = ol.getNamespace("MAPI") ns.logon "","",true,false Set newMail = ol.CreateItem(olMailItem) continued ..... However when I set the task as "Run whether user is logged on or not", it invokes the batch file, however it never finishes. I run this manually from task scheduler and it never gets completed. After debugging I find that, it's stuck on the below line, it seems like it can't open outlook when running as "Run whether user is logged on or not". Set ol = WScript.CreateObject("Outlook.Application") I tried all the options, security, start in, priority etc. mentioned in this thread, but nothing worked. Will it ever work with MAPI and "Run whether user is logged on or not" or will I have to use CDO to resolve this issue? I need to make this work when we logged off from the server so that it sends email when there is an error in server. Thanks! My server OS : Windows Server 2008 Enterprise SP2 Also, fyi, i've outlook 2007 SP2 installed and configured for a shared email box in the server. So, when it sends an email, it'l lcome from shared email box.
Free Windows Admin Tool Kit Click here and download it now
April 4th, 2012 7:54pm

I am having this in my bat file which is run by windows scheduler job in Windows server 2008 (R2):

--------------------------------------------------------------

echo

c:  

cd C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn     


dtexec /F "C:\GROW_DEV\Interfaces\Deployment\Vendor\GrowVendorSolomonImport.dtsx"

---------------------------------------------------------------
This option is running when the user is logged on option is checked but not running when run whether the user in logged on or not is selected in jobs.
How can I make it run?

April 13th, 2012 12:23pm

As this seems to be the best answer thread on this problem, I thought I'd add my experience in case it helps anyone else.

I had a batch file that ran fine on it's own, and also when the "Run only when user is logged on" was ticked, but had strange behaviour when "Run whether user is logged on or not". It showed the status as "Running" for ages until it timed out, when it went back to "Ready". After much digging around I found a comment on another thread that said that there was no GUI when "Run whether user is logged on or not" is selected. I tested this with a very simple batch file. This works OK and the task finishes when "Run whether user is logged on or not" is set

@echo off
echo hello this works then %time% >>C:\Test.log

this however, just keeps on running (there is no "task Completed" line in the history, although there IS an "Action Completed" line , presumably because it is trying to display on the command prompt. Note however, that it still writes out to the log

@echo off
echo hello there
echo hello this works then %time% >>C:\Test.log  

I then went back to my batch file and found a subtle problem that was the same issue. Due to some permission/mapping issues, I ended up having to explicitly delete and recreate a mapped drive using net use

net use X: /delete
net use X: \\Otherserver\xbackup <password>  /USER:<servername>\Administrator

When I ran this directly, I noticed that when deleting, net use responds with "Deleted successfully" to the command prompt. It was this that was causing the task to carry on running and not finish. The solution was just to pipe the output to null as below, and all was well with the world.

net use X: /delete 2>NUL >NUL
net use X: \\Otherserver\xbackup <password>  /USER:<servername>\Administrator 2>NUL >NUL





Free Windows Admin Tool Kit Click here and download it now
May 2nd, 2012 1:08am

I'm keeping a VPN connection alive by using a batch file to write the date and time to a text file and then copying that file across the VPN connection. If I use the UNC version of the destination, it works, but if I try to use the drive letter it's mapped to, it doesn't work.

To get to this point, I scanned through about three years of posts in this thread, and I tried many of the suggestions. In my case, the key concept is that mapped network drives will not work, but UNC addresses do. Suggestions about running as Administrator, Starting in the same directory as the one the batch file is in, only running when logged in, and issues with permissions were not relevant. All I had to do was to modify the copy command in the batch file to use the UNC version as the destination rather than the mapped drive letter, and everything worked.

  • Proposed as answer by trippap Wednesday, May 02, 2012 2:56 AM
May 2nd, 2012 2:56am

This solved my problem "cant start the task schedule", Thanks

Hi,


I think its because you need to fill in the "Start In (Optional)" field. There you need to enter the path of .BAT file! Go to your task's properties, Actions, Edit and you will find it.
Try it!

Free Windows Admin Tool Kit Click here and download it now
May 14th, 2012 6:22pm

I got this problem as well under w2008r2 environment (SBS2011)

This is unbelievable..... I've lost 2 days to debug this crappy stuff.... I really can believe that MS doesn't make some patch for this mess!

Anyway, I've fixed up the bug using "ADMINISTRATORS" as GROUP for account.

I've also try to editing the batch and adding the string

set __COMPAT_LAYER=RunAsInvoker

at the top of the batch file..... NO RESULT

.... I've lost 2 days... 18Hours.... 1080  minutes for a stuff like this..... simply unbelievable !!!!!

The main problem is related on "output file" using the syntax like   >test.txt

If you put >test.txt at the end of the line where the command is, the batch doesn't work inside the scheduler.....

I really would like to know whats wrong


  • Edited by Gate Array Friday, May 18, 2012 4:27 PM
May 18th, 2012 3:50pm

Co to windows\system32\cmd.exe and give the account full access permission. Also if ou are running the bat manually from task manager you will not see it if it is running as another use it runs in the backround
  • Proposed as answer by CCraddock Thursday, May 24, 2012 2:15 PM
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2012 2:15pm

Hi,
I think its because you need to fill in the "Start In (Optional)" field. There you need to enter the path of .BAT file! Go to your task's properties, Actions, Edit and you will find it.
Try it!
The right soluction
May 31st, 2012 7:08am

Guys,

Today also I noticed Windows Sceduled Tasks C:\WINDOWS\Tasks has not started. It was sceduled for morning 5 AM Evryday. It is calling >bat file to run around 600 SSIS ETL Packages. When I opend C:\WINDOWS\Tasks & checked Status of Each Scheduled Tasks, It is displaying "Could not Start". Other than memory, there can be other reasons.

Anyone has faced similar issue pls suggest me solution.

If manually, I am starting Task, after sometimes System is hanging.

http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/e2e2f1e8-a8f8-4a13-bbe7-371e7d89ad57

http://stackoverflow.com/questions/865653/how-to-troubleshoot-windows-scheduled-task-not-running

http://technet.microsoft.com/en-us/library/cc721846.aspx

http://support.microsoft.com/kb/308558

http://technet.microsoft.com/en-us/library/cc783861(v=ws.10).as

June 4th, 2012 1:22am

Hi All,

After 7-8 Days fight, system is responding now. (I did not changed anything in Packages & Configuration). Today I received a package from offshore & in Readme It was written to run this package for Full load. So i tried to run this alone package manually because when I run packages (680 Total), CPU Utilization was going 100%.

So I ran today Package by using Utility but it got failed. I added that package to BIDS & found that It was not able to connect to Target DataBase. Showing Error: "Test connection failed because of an error in initializing provider. [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied." But I was able to loging to DB from SSMS, with no error.

 I searched in google & found few links:

http://www.fixpchelper.com/?k=Initialization+Failed&tid=A1443&gid=1018589375

http://repairpcerror.org/Connection-Error-Repair/repair/

http://omensblog.blogspot.com.au/2009/03/dbnetlibconnectionopen-connectsql.html

I Just follewed Last Link steps:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Set the SynAttackProtect entry to a DWORD value of 00000000. To do this, perform the following steps:

Click Start, click Run, type regedit, and then click OK.


Locate and then click the following registry key:


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters


On the Edit menu, point to New, and then click DWORD Value.


Type SynAttackProtect, and then press ENTER


On the Edit menu, click Modify.


In the Value data box, type 00000000. Click OK.


Quit Registry Editor.


Restart the computer that is running SQL Server

I restarted SQL Server instead of System & after that I was not able to Login to DB SSMS. Actually It satrted pointing to some other IP. Informed my DBA, & he restarted System & After that all is well:)

I got another Link:

http://technicallyeasy.net/2010/10/how-to-fix-keyset-does-not-exist-for-scheduled-tasks-in-windows/

General page initialization failed.
The specific error is:
080090016: Keyset does not exist
An error has occurred attempting to retrieve task account information.
You may continue editing the task object, but will be unable to change the task account information.

Steps to Correct the Keyset Does Not Exist Issue

After performing some research, I found out that the local system private keys used by the Cryptographic Services service had become corrupted. I simply used the following steps to correct the issue:

    • I stopped the Cryptographic Services service.
    • I then double-clicked My Computer, and then clicked Folder Options on the Tools menu.
    • On the View tab, I clicked Show hidden files and folders, and then clicked OK.
    • I deleted all of the files in the C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\S-1-5-18 folder.
    • I then restarted the Cryptographic Services service.
June 6th, 2012 5:28am

Thank you so much Brian.  I followed your instructions and my schedulers are working now.  God Bless You!!!
Free Windows Admin Tool Kit Click here and download it now
June 11th, 2012 7:12pm

This is simply intolerable. Microsoft, you have had THREE AND ONE-HALF YEARS to fix this but we're still stuck with kludgy workarounds and descriptions of "all ya have to do is..." and none of it works.

My batch file is all local to the server, runs a WinSCP script, also on the local server and will run under my account when I'm logged in but will not run under my service account, whether logged in or not. I have done everything...EVERYTHING...on this thread and have had negative results.

This is a clear demonstration that Microsoft just does not give a rat's a__ about its customers. With each "improvement" since XP, Windows has gone from worse to worst. Where are you getting your programming "talent?" There is simply no excuse for this deviation from what used to be the model of programming and documentation best practices. There is zero (0, null, nada) documentation anywhere for this task scheduler. Why? I can guess but my guess isn't very PC and I'll hold back.

June 15th, 2012 8:55pm

Hi,

Many thanks Branfarm!

This simple solution solved my same issue for running a batch with a scheduled task.

thanks.

Free Windows Admin Tool Kit Click here and download it now
June 20th, 2012 5:27pm

Yes.  My problem seemed to be because I had a path using a mapped drive in my .BAT file, and I had the "Run whether logged on or not" checked.  Once I changed my mapped drive path to a full UNC path (\\192.168.etc.etc.\Share\etc...) the scheduled .bat file ran correctly.

What disturbs me is that Task Scheduler reports the task a completed successfully, when clearly it does not!

June 22nd, 2012 4:17am

Great hint , I did all of the above still had problem. The hint above solved my problems my destination in one program was a CIFS share and likewise my source in another program was a CIFS share on a SAN. So I replaced the mapped drive which had a drive letter and path with the name space ie with \\abc.ab.local\dfs\SOURCE_FOLDER and it worked thanks guys

pponnapa

Free Windows Admin Tool Kit Click here and download it now
June 26th, 2012 8:57pm

This is the one that did it for me!  Thanks so much!  My OS on this box was SBS 2011 Standard.

Thanks again,

Nick Terrell

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 


July 13th, 2012 7:36am

Hi Brian,

I followed the instructions, That is worked for me :) Thanks a ton :)

Free Windows Admin Tool Kit Click here and download it now
July 20th, 2012 5:49am

This resolved it for me.

Many thanks!

August 20th, 2012 11:36pm

This solution worked perfectly for me.  Thank you!!
Free Windows Admin Tool Kit Click here and download it now
August 21st, 2012 5:58pm

Running with highest privleges resolved the issue for me too.  I was about to rip out all my hair - thanks for the help.
September 11th, 2012 8:19pm

#2 seems to have fixed it for me -- I already had everything else setup as noted.  Thank you very much.

I second that

Free Windows Admin Tool Kit Click here and download it now
September 17th, 2012 7:01pm

I had similar issues. Eventually I put the .bat file in the Windows\System32\ folder to be able to run in from anywhere and anytime in the command prompt. This eliminated the need to specify a path for the .bat file.
October 3rd, 2012 9:54pm

I had issues with this also. I have a windows 2003 domain and im running this email powershell script task from a windows 7 workstation. Man has this been frustrating! I finally got it working with bits and pieces of info here. I tried permissions settings on the files, using domain admin credentials, run as administrators, run logged with out login checked/unchecked. NOTHING! Somewhere in this post was mentioned login as batch job rights in GP. i checked the workstations local gp editor to see what setting was there. It was pulling a rouge setting in one of our GPO's that gave a specific user account those rights (wasn't even an ent/domain/ws admin). i changed the gpo on the our DC to give domain administrator, administrators group, and backup operators permission to login as batch job. That was it. I guess GP trumps even domain admin rights? Well at least i have automated emails to show for my week of aggravation!
Free Windows Admin Tool Kit Click here and download it now
October 4th, 2012 2:54pm

Great summary Brian, and yes, checking all of those steps fixed it for me. (But just in case this helps someone out there in answer-land, I was dumbfounded for a while when the script stopped working. Until I reviewed my script again. Seems I had inserted a PAUSE command during one of the many debugging efforts, and that was causing the .bat to hang and never complete!)
October 11th, 2012 7:35pm

I just thought I'd add my two cents on this, as this has been causing me a lot of frustration, but I have found a workaround (or kludge, if you prefer).

My VBScript was working fine on its own, but would not work from the Task Scheduler. However, I found that the 'net use' solution was the effective one here. It seems Task Scheduler does not like the VBScript equivalent of Net Use, but if you use a batch file with net use in that invokes the script, it'll work fine. That's what worked for me, anyway.

This has proved to be an excellent forum for giving me options to try (and there were a lot of them), so thanks for all your input, and jeers to the fact that we have to resort to support by forum for broken applications that don't get fixed even after all this time.

Free Windows Admin Tool Kit Click here and download it now
October 25th, 2012 11:22am

This worked for me as well.
October 26th, 2012 4:11pm

Batch files aren't supported (*.bat)

Convert it to CommandLine Script by simply changing it's extension to [*.cmd]

good luck - msfsgl ;)

Free Windows Admin Tool Kit Click here and download it now
October 31st, 2012 8:55pm

I use the create basic task wizard to create the job with default setting. Check the "Run with high privileges" in the job properties. The job can run smoothly.
  • Edited by Super Simon Friday, November 02, 2012 7:05 AM
November 2nd, 2012 7:04am

omg!!! this worked for me! I was loosing faith... 
Free Windows Admin Tool Kit Click here and download it now
November 6th, 2012 6:08am

I ran into pretty much the same issue this week. I had been running this batch file on some old 2003 R2 x64 boxes for years with no issue. When trying to run it on a 2008 R2 x64 box it appeared to not run with a scheduled task but of course runs fine manually. After 2 days of banging my head on the desk, I found the problem.

In my batch file, I use a variable to set my log file location.

Like this: SET LOG="%CD%\xxxxxx.txt

When I changed that to the path instead of a varriable, it worked like magic..

November 8th, 2012 10:06pm

I could not agree more.  This is total nonesense that it takes hours to get this simple schedule to work.  I have tried for days to get simple VS2008 compiled apps to run scheduled and still....nothing.  I have tried everything above.

The paths and files all have the right admin rights.

The users are part of Local Admins group.

Run only when logged in is unchecked.

Start In has correct path.

This is rediculous.

Free Windows Admin Tool Kit Click here and download it now
November 28th, 2012 5:10pm

Hi,

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

Sorry for the basic question, what exactly to change these settings? General tab of what?

December 3rd, 2012 9:34am

Hi,

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.


Well I suppose I ought to keep the ball rolling and be the first in 2013 to say that this problem keeps on and on.

I have tried all the suggestions here; changing paths, shortening names running as different explicit users, renaming to .cmd ... however this suggestion above confuses me. While I can search for the Servername\Administrators group, when this is selected, true, the "Run whether user is logged on or not" is greyed out but the option "Run only when user is logged on" is still selected (as the only selected option).

I am wondering if those users that say that this fix worked for them was because at some point when the scheduled task was due to run, there was a user who was a member of the admin group logged in at the time.

I cannot get my bat file to run (also renamed it to .cmd) unless the option "Run only when the user is logged on" is enabled. I need to get this to run when no user is logged in!

If I right click and select run, on the selected  task, as long as I have "Run only when user is logged on" and that user is logged in, then the task runs. As soon as I change the option to "Run whether user is logged on or not" then the task starts an MSACCESS.exe process (as seen from task manager) but never runs to completion.

For information, the bat files starts an Access database which runs a macro which does a select, runs some code and ftps some voucher codes to a website. Note that this runs fine with the "Run only when user is logged on" even when I am logged on as a different user to the server (to initiate the run by right clicking) but the user associated with the scheduled task has a login in session enabled on the server.

To get around this issue for now I am having to leave a login session on the server to allow the schedule task to run each day. Madness. I have wasted days trying to sort this!

The only change needed to stop this from working is setting the job to "Run whether user is logged on or not"

It's been 25 years since I touched unix but I feel a cronjob coming on!

AJ

Free Windows Admin Tool Kit Click here and download it now
January 4th, 2013 3:46pm

It really would be great if Microsoft would come up with a fix for this.  It has to be some sort of a bug.  I also have a batch file that a scheduled task will not run.  It says it runs it just fine, but it does not.  I can click on the batch file and it runs, but the scheduled task won't run it.

I too have tried changing privileges, and file names.  No luck.  I've been working on this off and on for about six months now.  So far my only option has been to login once or twice a month and manually run this batch file and have another crack at Task Scheduler :-(


May 2nd, 2013 2:51am

Just wanted to say thanks for posting...been working on this problem for 2 days....

for me it was the permissions on the bat and log files

Free Windows Admin Tool Kit Click here and download it now
June 14th, 2013 2:40am

thank you for your sharing , it saves me a lot of time,I had problem with #2 and #5.

  • Edited by Chen1 Saturday, June 29, 2013 7:30 AM wording error
June 29th, 2013 7:28am

Brian Vandemark's note to fill in the "optional" start-in path is one of two things you need to do (if you want to run whether logged in or not).

Not using mapped drive letters is the other: I_live_in_TN's "net use" works, but dagosta: kudos for identifying that the mapped drive (that only exists in the user's space) was the cause; I'm just not sure that a .bat referencing a .bat (that references a mapped drive) is the way around it.

To concur with dmallinak, some people may want to just replace all of the references to mapped drives (in your .bat) with the UNC and skip the mapping in the script (i.e. don't bother using "net use"); however, use the IP address and not the computer name (e.g. instead of "robocopy c:\folder n:\folder", use "robocopy c:\folder \\10.0.0.2\folder"); depends on the environment you are in (but this note will save many!).


Or as others have noted, set it only to run when logged in (and lock your computer, as opposed to logging out)--then you don't need to worry about start-in path and if your .bat references a mapped drive (as it used to work in the now defunct XP).

Free Windows Admin Tool Kit Click here and download it now
July 11th, 2013 6:15pm

When i removed double quotes, it worked in that the status changed from ready to running - but it still didn't actually run the batch file because it didn't bring up the cmd window although the task was running. I also know it didn't run because the results did not manifest.

Server 2008 R2 Enterprise SP1 here

So as Bnatutowa said, I put the path to my .bat file in the Start in field and that fixed it.

Thanks


  • Edited by Andrew Osiname Monday, July 22, 2013 9:07 PM operating system update
July 22nd, 2013 9:06pm

Not sure if this is too old now or been mentioned previously as incredibly long post...

by ticking 'run with highest privileges' with 'Run whether user is logged on or not' worked for me. 

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2013 9:53am

I had the following line in my batch file:

del /q "c:\myfolder\subfolder\*.*"

I created this simple batch to delete all my folder contents and by using Windows' Schedule, it runs every 10 minutes.

It works fine if run manually, but never seemed to run when in a schedule in Windows Server 2008 64 bit.

I removed the double quotes as bthorwall proposed and it worked!

del /q c:\myfolder\subfolder\*.*

THANKS!

September 13th, 2013 12:28pm

This worked for me: Server 2008 R2 x64
Free Windows Admin Tool Kit Click here and download it now
September 19th, 2013 6:45pm

I get the same problem when I run a backup.bat !

At last ,I found I make a mistake , I use a time to be the file name ,when the time it's less then 12 o'clock, the backup.bat can not run ,because  the command get a space.SO the grammar is wrong .

Hope that can help!

December 4th, 2013 6:18am

After trying just about everything else this was the only one that worked.  
Free Windows Admin Tool Kit Click here and download it now
December 18th, 2013 9:04pm

I also had the same issue in setting up a Scheduled Task in one of our Production setup. I did what you said exactly, and now it is working fine. Thank you very much.
December 22nd, 2013 6:45am

I was stuck with this for months, finally got it, here's what you need to do:

- get rid of quotes in the command field

- fill in the location

- if you use network locations or  mapped drive specify the full path: \\server\share

Free Windows Admin Tool Kit Click here and download it now
December 27th, 2013 12:57pm

Hi, Great!

It solved my problem.

Regards.

January 3rd, 2014 10:29am

Thank you very much. That tip solve my problem!.
Free Windows Admin Tool Kit Click here and download it now
January 13th, 2014 6:33pm

Hi

I have the same issue, but with a powershell script that uses WINSCP and also I cannot run the task with the option "whether user is logged on or not".

Were you able to find a fix?

Thanks

January 22nd, 2014 3:53pm

Hi AJ,

Nice to see a thread 5+ yrs old and the issue still persists :)  Anyway this is a very long thread...have no idea if your issue was resolved herein, but wanted to post my fix as I lost an entire day trying to get this thing to work. 

I had the exact same issue as my bat file would run fine under "Run only when user is logged on", but didn't when I switched it to run whether logged on or not.  I found a technet article which states the following:

If your task requires access to network resources, you cannot use S4U; doing so will cause your task to fail. The only exception is the case where constrained delegation was established between the computers involved in the operation. S4U functionality is only available within an environment where all the domain controllers (DCs) in the domain are running the Windows Server 2003 or later operating system. If you are using the S4U functionality, the task will not have access to encrypted files.

http://technet.microsoft.com/en-us/library/cc722152.aspx

S4U is basically the option that states "Do not store password.  The task will only have access to local resources".

My particular bat file was copying files over the network, so this was failing.  I never chose this option...I know I never chose it because I specifically remember looking at it and not choosing it.  When I went to edit the settings it was still UNchecked.  However, I checked the box, THEN unchecked the box.  Once I hit ok I was prompted for the first time for my credentials for the admin running the task.  After I input the password and tested all ran fine.  Horrible bug that MS needs to fix...

Anyway I hope this helps someone.

Free Windows Admin Tool Kit Click here and download it now
February 6th, 2014 3:52pm

The was a life saver.... Thank you!
March 4th, 2014 5:46pm

Here were are in 2014 and I just installed a new server and ran into this "run whether user is logged on or not" problem. Although I have other tasks (for SQL server) which run with this option, batch file launch is broken with it. When I select "run only when user is logged on" then it works. Bah! What a waste of time and energy to solve! I've always hated Task Scheduler, and on my prior Server 2000 box I used sched instead, due to problems like this, but I figured that this is now more than a dozen years later (I'm running Server 2012 R2) and things should be easier. Ffft! Anyway, changing the task owner to the Administrators group rather than an individual user, as I discovered on this thread, made it work for me, just at the point I was going to install System Scheduler from Splinterware, which I was hesitant to do because then I'd have two schedulers to keep track of. Thanks!
Free Windows Admin Tool Kit Click here and download it now
April 12th, 2014 3:42pm

I finally found my problem. I hope this wasn't already mentioned.

I was trying to run a .BAT file on a network drive. The folder contained an "@" symbol. As soon as I removed the "@" symbol everything worked fine.

I hope this helps someone else.

April 17th, 2014 3:07pm

THANK YOU!!  After trying all the other options, this one task would not work unless I made the change in the Start In Path by adding the final backslash.  I truly appreciate these forums!!
Free Windows Admin Tool Kit Click here and download it now
May 7th, 2014 9:44pm

Thanks... I was facing the same trouble and your solution above solved it for me.. 
June 11th, 2014 9:09am

I had this same issue.  Adding the folder path to the batch file in the Start In field fixed the problem.
Free Windows Admin Tool Kit Click here and download it now
June 24th, 2014 1:57pm

You legend!!! that was it!
July 1st, 2014 3:47am

Yes!  Thank you for this tip.  Makes sense... now.
Free Windows Admin Tool Kit Click here and download it now
July 10th, 2014 5:23pm

This has been bugging me for 6 or 7 months. I don't have admin rights to the box and the guy who does is very busy... so I've felt the range of emotions mentioned above.

I tried most everything above as well. But what seemed to get my processes processing, was ...

  • on the General tab, I clicked the Change User or Group button
  • in Select User or Group(first smaller dialog box), I clicked the Advanced... button
  • in the next Select User or Group (second bigger dialog box), I clicked the Find Now button
  • in the Search results I selected the Administrators (a group) and it returned SERVERname\Administrators into the "Enter the object name to select" entry in the previous dialog box
  • then I clicked OK and returned to the General tab above
  • the options to Run only when user is logged on and Run whether user is logged on or not are no longer available
  • then I made sure that the Run with highest privileges was checked
  • then I clicked OK and during the next scheduled time to run ... it ran

Thanks to everyone who has contributed, I feel a little smarter today.

 

Thank you!

 

I tried all other solutions and none of them worked for me unfortunately, but this one did the trick! Thanks again.

This Did the trick for me.

I was using a admin account however it still failed.  Once i changed the user to the administrator group it ran.

Excellent solution


  • Edited by Paul0336 Sunday, July 13, 2014 11:45 AM
July 13th, 2014 11:44am

This solution works perfect! I am surpised to find this solution at the end of a 5 year old thread, why has this not been solved in windows??

Free Windows Admin Tool Kit Click here and download it now
September 15th, 2014 12:09pm

Dear_Austin,

Thanks so much! This worked like a charm on my local desktop!

Thanks so much!

What a butt pain, but your answer really did it!

Thanks for sharing!
Cheryl

November 13th, 2014 11:47pm

2014- I suspect many of the folks who this or that worked for them where running this logged in.

Just closing a remote desktop is not a log out.  Maybe acceptable solution for many but not for us.

After going through everything, the only way to get this to work when not logged in was to have our systems guys create a doman level admin service account. Then add that to the server into the administrators group.

Go through all the bit about setting permissions directly, etc...

Then set the account to run as as the new service account.

The odd thing was, the Task, which called a batch file to reboot the server would not run as that account when logged in with an admin account.  

But when I logged out, the task would run as scheduled.  Go Figure...

Should have just picked up that third party software.  3 freaking nights of this.

Ridiculous.  You know why Msoft won't comment, it's all part of the new security methods and they don't want to give anything away.  

Free Windows Admin Tool Kit Click here and download it now
November 26th, 2014 3:26am

Hi, I think its because you need to fill in the "Start In (Optional)" field. There you need to enter the path of .BAT file! Go to your task's properties, Actions, Edit and you will find it. Try it!

Thank you so much! Worked like a charm.


  • Edited by Symes39 Wednesday, December 10, 2014 5:05 PM
  • Proposed as answer by zsolt.szasz Monday, January 19, 2015 12:50 PM
  • Unproposed as answer by zsolt.szasz Monday, January 19, 2015 12:50 PM
December 10th, 2014 5:03pm

None of the solutions from above worked for me!
I have found a solution althought, something totally different. The following settings which worked for me are:
Run whether the user is logged on or not
Run with highest privileges
Configure for Windows Server 2003, Windows XP ...
Action: start a program
Program/script : cmd
Add arguments: /c start "" "youre_bat.bat"
Start in (optional): path to the bat file
I also added in the enviroment the path to the executable which is called by the bat file.
Hope it helps you!



Free Windows Admin Tool Kit Click here and download it now
January 19th, 2015 1:23pm

Thanks Nick, that worked for me!
February 13th, 2015 11:33pm

I tested the "run whether user is logged on or not" problem on Windows Server 2012 R2 and confirm the problem persists. After some research, I guess I found the cause.

If it is selected, the system will try to create a directory C:\Users\Default\AppData\Local\IsolatedStorage (on ordinary Windows installations) and fail. So, you can give write permission to the account on C:\Users\Default\AppData\Local to resolve the problem.

I guess this is a bug. The folder location to be created on is wrong.


  • Proposed as answer by gnaka Wednesday, February 25, 2015 9:20 AM
  • Edited by gnaka Wednesday, February 25, 2015 9:25 AM
Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 9:17am

I wanted to summarize all of the steps I performed to solve my problem.  I would guess that maybe some of these are not needed, but I'll list them all to hopefully help you get it working

1) Make sure that the task is set to "configure for Windows Vista or Windows 2008" on the first page of the task properties (under the "general" tab)
2) Make sure that the task is set to "start in" the folder that contains the batch file: open the task properties, click on the "actions" tab, click on the action and then the "edit" button at the bottom.  In the "Edit Action" Window there is a field for "start in (optional)" that you set to the path to the batch file.
3) Make sure that the task is running as an account that has explicit "Full access" permissions to all these things:  The .bat file itself,  the folder containing the .bat file, and the target files/folders that are affected by the .bat script.  Inherited permissions didn't seem to work for me.
4) Make sure that the account running the task is a member of the local "administrators" group for this machine
5) Make sure that the task is set to "run whether logged on or not"
6) The Task should run successfully with expected output when you right-click on the task and select "run"  If it does that then it will run successfully when you are logged off.

Good Luck!

I consider the above steps as correct but would like to add that in my case this was not the complete solution. I had a copy command to a mapped network drive and had the script copy to a drive letter. Only after I change the drive letter into the machine\share name, the Task Scheduler was able to run the task.
For example I change the path from "W:\copydest\" into "\\SERVERNAME\SHARE\copydest\"

February 26th, 2015 10:43am

7 years later and still a problem.  running the task as the local pc administrator worked !!!!!  Thanks to this forum !!!!!
Free Windows Admin Tool Kit Click here and download it now
March 3rd, 2015 4:13pm

If the .bat is trying to access any exe (in my case) then its logical that the "Start In" field need to be counted in so that it looks in current directory where .bat is located.

April 16th, 2015 11:45am

Make sure the account you are running the scheduled task with has allow run as batch file rights either in local policy or group policy.
Free Windows Admin Tool Kit Click here and download it now
April 27th, 2015 5:02pm

seriously?  I am finding the same observation on WS12.  I cannot run  batch file via a scheduled task using a domain account that is a local admin??
April 29th, 2015 7:37pm

I have got to say, this is potentially the worst response I have ever seen. This problem is so annoying... the .bat script runs fine from the command prompt, but will not run in the Task Scheduler. I've searched for hours trying to find a solution and the solution from someone who WORKS AT MICROSOFT is this? Come on! Try harder! This is ridiculous!
Free Windows Admin Tool Kit Click here and download it now
May 1st, 2015 4:07pm

This worked for me. I am running Server 2012 R2 and was unable to run a batch file running a simple robocopy command transferring files from the local server to a NAS. I am wondering if the act of re-establishing the drive mapping gets the credentials in a form that the unmanned script can access.

Would never have guessed unmapping and remapping the drive worked...

Had the same issue running powershell scripts, will give it a shot and see what happens.

May 7th, 2015 7:53pm

I've not checked which of these things it was; I think either 2 or 3 (suspect 2 as I had already applied 3 to some of the files in question), but I'm glad this thing is finally, after hours of googling and trying solutions that didn't work, running. Thanks very much for this 5.5 year old post. In my case it was a .bat in Server 2012 that refused to execute as a scheduled task.
Free Windows Admin Tool Kit Click here and download it now
May 21st, 2015 8:33pm

That worked for me, thanks!
June 9th, 2015 2:24pm

Guys all you have to Do is create schedule as you want/required. But...

1.try it using CMD.exe. (admin profile)

2.In Task General tab->Change User/Group -> advanced-> search-> select administrators group

3.tick Run with highest privileges

4.Make sure to enter batch file containing folder to Action Tab-> Edit -> Start In  field.

5. Click Ok

Trust me ..This worked for me !!!!

Free Windows Admin Tool Kit Click here and download it now
June 10th, 2015 4:57am

Just to say that following the steps by Brian, and in particular step 2, did the trick for me.

Thanks

Nino

June 19th, 2015 3:48am

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

Other recent topics Other recent topics