locked
Scheduled task won't run .bat file RRS feed

  • Question

  • 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? 
    Friday, September 19, 2008 6:05 PM

Answers

  • 7 years later and still a problem.  running the task as the local pc administrator worked !!!!!  Thanks to this forum !!!!!
    • Marked as answer by Alex Lv Thursday, April 16, 2015 1:37 AM
    Tuesday, March 3, 2015 4:13 PM

All replies

  •  

    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

     

    • Marked as answer by Tim Quan Friday, September 26, 2008 2:42 AM
    • Unmarked as answer by Tim Quan Wednesday, June 1, 2011 3:15 AM
    • Proposed as answer by Larry At ThePhil Tuesday, October 18, 2011 1:32 PM
    Monday, September 22, 2008 6:54 AM
  • 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 3, 2011 1:42 PM
    Thursday, July 9, 2009 11:17 AM
  • 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
    Friday, July 17, 2009 1:38 PM
  • 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.
    Thursday, August 13, 2009 8:02 PM
  • 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
    Tuesday, August 18, 2009 2:40 PM
  • 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?

    Wednesday, August 19, 2009 10:07 PM
  • 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
    Thursday, August 27, 2009 5:21 PM
  • 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
    Friday, August 28, 2009 8:02 PM
  • 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!


    Monday, August 31, 2009 5:18 PM
  • Ive still got the same issue. SBS 08. Batch file will 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 2, 2009 9:35 PM
    Wednesday, September 2, 2009 5:25 AM
  • 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 2, 2009 9:36 PM
    Wednesday, September 2, 2009 9:36 PM
  • I had a problem with security account settings whitch did not allow the task to run.
    Thursday, September 10, 2009 6:57 PM
  • 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
    Wednesday, October 14, 2009 4:20 PM
  • 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)
    Wednesday, November 25, 2009 8:06 PM
  • 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.
    Friday, December 11, 2009 4:00 PM
  • 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

    Friday, January 8, 2010 3:19 PM
  • 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
    Friday, January 8, 2010 9:31 PM
  • 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 5, 2011 5:38 PM
    Monday, February 1, 2010 2:14 PM
  • 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
    Tuesday, February 2, 2010 6:21 AM
  • 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 7, 2011 6:41 PM
    Tuesday, February 2, 2010 9:02 PM
  • 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.
    Thursday, February 18, 2010 6:49 PM
  • 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. 
    Wednesday, March 3, 2010 4:42 PM
  • 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 7, 2015 7:51 PM
    Thursday, March 25, 2010 1:31 PM
  • 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

     

    Wednesday, April 7, 2010 11:17 AM
  • By giving the optional start in parameter, works for me .. Thanks a ton !! :)
    Thursday, April 22, 2010 1:56 AM
  • 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
    Monday, April 26, 2010 1:47 AM
  • Updating start in optional parameter with "directory path" of the executable worked for me. Thanks to all.
    Monday, April 26, 2010 8:10 AM
  • #2 Work for me Thanks a lot!!!
    Monday, May 3, 2010 6:22 PM
  • 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?

    Tuesday, May 4, 2010 6:00 PM
  • 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...
    Thursday, May 6, 2010 11:00 AM
  • 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...

    Thursday, May 6, 2010 11:54 AM
  • I had the same problem and this worked for me. Thanks!!
    Sunday, May 16, 2010 5:51 PM
  • 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 .

     

    Tuesday, May 25, 2010 12:37 PM
  • Thanks it worked for me!!!
    • Proposed as answer by PCGuidance Friday, May 1, 2015 2:43 PM
    Thursday, May 27, 2010 3:37 PM
  • Usefull information, even almost a year later.  Thanks Brian.
    Thursday, May 27, 2010 7:14 PM
  • 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

    Wednesday, June 16, 2010 3:50 PM
  • 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
    Wednesday, June 16, 2010 3:52 PM
  • 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.

     

     

     

    Thursday, June 24, 2010 3:42 PM
  • 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

    Wednesday, June 30, 2010 1:35 PM
  • 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

    Thursday, July 1, 2010 10:16 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

    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
    Wednesday, July 7, 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.

     

    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 1, 2012 8:22 PM
    Thursday, July 15, 2010 1:41 AM
  • 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.

     

    Saturday, July 24, 2010 7:39 PM
  • 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.

    Friday, July 30, 2010 1:32 PM
  • 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
    Friday, July 30, 2010 2:35 PM
  • Thanks Bnatutowa, filling in the "Start In (Optional)" field did the trick for me!
    Wednesday, August 4, 2010 7:40 PM
  • 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.
    Thursday, August 5, 2010 11:43 AM
  • 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.

    Monday, August 16, 2010 10:17 AM
  • 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

    Thursday, August 19, 2010 1:30 PM
  • 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!
    Monday, August 23, 2010 8:17 PM
  • 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????!
    Thursday, September 9, 2010 8:38 AM
  • >> Tired of having to constanly fight with Windows to get something done

    Ditto

    Thursday, September 9, 2010 8:42 AM
  • 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!
    Thursday, September 9, 2010 10:01 PM
  • 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

     

    Tuesday, October 5, 2010 2:22 PM
  • 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.

    Monday, October 18, 2010 2:57 AM
  • 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

       

    Monday, October 18, 2010 4:38 PM
  • 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?

     

     

    Tuesday, October 19, 2010 10:14 PM
  • Thanks, It s seems to solve my problem.

    Nice Post!

    Monday, November 1, 2010 4:46 PM
  • 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
    Tuesday, November 2, 2010 3:38 PM
  • 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? 

    Tuesday, November 2, 2010 4:56 PM
  • Thanks for the information if i put the path in where the batch file resides, it works fine. Thanks for the information!!!
    Wednesday, November 3, 2010 5:05 PM
  • For all that I wrote above. It ran one night and never worked again. Anyone else?
    Friday, November 5, 2010 1:46 PM
  • 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
    Wednesday, November 10, 2010 2:46 PM
  • 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!!
    Wednesday, November 17, 2010 1:01 PM
  • Thanks Mike your answer was perfect my problem has solved.

    Tuesday, November 23, 2010 10:19 AM
  • 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.

    Friday, December 10, 2010 7:46 AM
  • 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 :-)

    Friday, December 10, 2010 10:18 AM
  •  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!

    Monday, December 13, 2010 3:38 PM
  • 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.
    Monday, January 10, 2011 2:21 PM
  • 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.

     

    Monday, January 10, 2011 8:38 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.

     

      

    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.

    Wednesday, January 12, 2011 3:21 PM
  • This fixed it.
    ale12345
    Tuesday, January 18, 2011 8:06 PM
  • 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.

    Monday, January 24, 2011 7:26 PM
  • 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
    Wednesday, January 26, 2011 2:44 PM
  • [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.

    Thursday, January 27, 2011 6:36 PM
  • 1. Using the local account 'Network Service' works for running our batch files as Scheduled Tasks in both Server 2008 and Server 2008 R2
    Thursday, January 27, 2011 9:23 PM
  • 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!
    Thursday, February 10, 2011 1:30 PM
  • 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.

     

    Monday, February 21, 2011 9:59 AM
  • 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 3, 2011 6:50 PM
    Monday, February 28, 2011 7:19 PM
  • I tried EVERYTHING, and this was the only thing that fixed it.  THANK YOU!!!!!!!
    Thursday, March 3, 2011 5:05 PM
  • 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

    Thursday, March 3, 2011 6:02 PM
  • 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!

    Thursday, March 3, 2011 10:27 PM
  • 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.

    Friday, March 4, 2011 3:49 PM
  • 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).

    Friday, March 18, 2011 4:47 PM


  • 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

    Thursday, March 31, 2011 11:30 AM
  • 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!

     

    Friday, April 15, 2011 9:36 PM
  • 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

    Monday, April 18, 2011 4:44 PM
  • 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.

    Tuesday, April 19, 2011 3:22 AM
  • 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....

    Monday, April 25, 2011 5:08 PM
  • 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

     

    Thursday, May 5, 2011 11:03 AM
  • 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

    Thursday, May 5, 2011 6:04 PM
  • This solution solved my problem.. thanks a million.
    Thursday, May 26, 2011 4:15 PM
  • 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 7, 2011 8:11 PM added context (posts aren't threaded here).
    Tuesday, June 7, 2011 7:53 PM
  • Bummer that  you would have to put your password in a bat file (AndyMay154). Security leak.
    • Edited by ScottS002 Tuesday, June 7, 2011 8:13 PM added reference (posts aren't threaded here).
    Tuesday, June 7, 2011 7:57 PM
  • 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 

     


     

    Thursday, June 9, 2011 10:09 PM
  • 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.

    Wednesday, June 15, 2011 7:01 AM
  • 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

     

     

    Monday, June 20, 2011 2:09 PM
  • 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.

    Monday, June 27, 2011 4:55 PM
  • 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

     

    Tuesday, June 28, 2011 12:29 PM
  • 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

    Tuesday, June 28, 2011 1:27 PM
  • 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

    Tuesday, June 28, 2011 1:42 PM
  • 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

    Tuesday, June 28, 2011 2:18 PM
  • Hi Matt,

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

    Ian

    Tuesday, June 28, 2011 2:26 PM
  • 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

    Tuesday, June 28, 2011 2:52 PM
  • 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

    Tuesday, June 28, 2011 2:56 PM
  • 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

    Wednesday, June 29, 2011 7:41 PM
  • 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?

     

    Thursday, June 30, 2011 10:15 PM
  • 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.
    Saturday, July 9, 2011 5:33 AM
  • 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

    Thursday, July 21, 2011 7:48 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.

     


    Thanks Dear_austin.  Your answer was the only one to fix my problem.  Now to get past the blat registry error......................
    Monday, July 25, 2011 9:14 PM
  • 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.
    Friday, August 5, 2011 6:01 PM
  • 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..

    Thursday, August 18, 2011 4:29 PM
  • 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...

     


    Doug Ivison
    • Proposed as answer by luisdev Wednesday, February 8, 2012 2:14 PM
    Friday, August 26, 2011 11:19 PM
  • Thanks for the help!!!  After banging my head against the keyboard repeatedly, I finally sought help and your suggests resolved our issue.  Thanks again!!

     

    Monday, August 29, 2011 6:27 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.

     

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

     

    Thursday, September 8, 2011 3:14 AM
  • 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.

     

    Saturday, September 10, 2011 2:01 PM
  • 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?

     

     

    Saturday, September 10, 2011 2:38 PM
  • 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.

     

    Thursday, September 15, 2011 8:43 PM
  • 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.

    Monday, September 26, 2011 2:36 AM
  • 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.

    Thursday, September 29, 2011 8:32 PM
  • 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.

    Thursday, October 13, 2011 11:02 PM
  • This solution worked beautifully!  Thank you soo much!
    Thursday, October 27, 2011 4:16 PM
  • #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!


    Friday, October 28, 2011 3:13 PM
  • 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 !!!
    Wednesday, November 2, 2011 3:16 PM
  • 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.
    Monday, November 14, 2011 6:23 PM
  • 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!
    Thursday, November 17, 2011 5:34 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.

     

    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!
    Monday, November 28, 2011 11:35 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 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 1, 2011 3:42 PM
    • Edited by TamusJRoyce Thursday, December 1, 2011 3:51 PM
    Thursday, December 1, 2011 3:42 PM
  • 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
    Thursday, December 8, 2011 9:26 AM
  • 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.
    Monday, December 12, 2011 11:55 AM
  • 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.
    Thursday, January 12, 2012 6:36 AM
  • This fixed it for me. Thanks. :)

    Tuesday, February 7, 2012 5:52 PM
  • 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

    Thursday, February 9, 2012 1:42 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.

     

    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.

    Thursday, February 9, 2012 10:44 PM
  • 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
    Friday, February 10, 2012 5:07 PM
  • 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.
    Monday, February 13, 2012 10:26 AM
  • 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?
    Tuesday, February 14, 2012 1:38 AM
  • 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.
    Tuesday, February 14, 2012 4:16 PM
  • 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!

    Tuesday, February 14, 2012 5:28 PM
  • 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
    Tuesday, February 14, 2012 5:42 PM
  • 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.

    Wednesday, February 15, 2012 10:30 PM
  • 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
    Saturday, February 18, 2012 2:59 PM
  • This resolved it for me...thanks!
    Tuesday, February 21, 2012 10:44 PM

  • 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.

    Thursday, February 23, 2012 6:03 PM
  • 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?

    Thursday, March 1, 2012 8:14 PM
  • 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

    Friday, March 9, 2012 4:05 PM
  • 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.
    Friday, March 9, 2012 4:15 PM
  • ...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)

    Thursday, March 15, 2012 2:08 PM
  • 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
    ============================================================================

     
    Thursday, March 15, 2012 5:40 PM
  • 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!  
    Friday, March 23, 2012 8:53 PM
  • This simple missing step, solve my problem!

    Thanks Bnatutowa!

    Monday, March 26, 2012 7:46 AM
  • 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
    Thursday, March 29, 2012 4:49 AM
  • 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.
    Wednesday, April 4, 2012 7:54 PM
  • 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?

    Friday, April 13, 2012 12:23 PM
  • 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





    Wednesday, May 2, 2012 1:08 AM
  • 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 2, 2012 2:56 AM
    Wednesday, May 2, 2012 2:56 AM
  • This solved my problem "can´t 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!

    Monday, May 14, 2012 6:22 PM
  • 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
    Friday, May 18, 2012 3:50 PM
  • 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
    Thursday, May 24, 2012 2:15 PM
  • 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
    Thursday, May 31, 2012 7:08 AM
  • 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).aspx



    Thanks Shiven:) If Answer is Helpful, Please Vote

    Monday, June 4, 2012 1:22 AM
  • 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:
    0×80090016: 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.

    Thanks Shiven:) If Answer is Helpful, Please Vote


    Wednesday, June 6, 2012 5:28 AM
  • Thank you so much Brian.  I followed your instructions and my schedulers are working now.  God Bless You!!!
    Monday, June 11, 2012 7:12 PM
  • 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.


    G. Steele at Sedgwick

    Friday, June 15, 2012 8:55 PM
  • Hi,

    Many thanks Branfarm!

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

    thanks.

    Wednesday, June 20, 2012 5:27 PM
  • 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!

    Friday, June 22, 2012 4:17 AM
  • 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

    Tuesday, June 26, 2012 8:57 PM
  • 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.

     


    Friday, July 13, 2012 7:36 AM
  • Hi Brian,

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

    Friday, July 20, 2012 5:49 AM
  • This resolved it for me.

    Many thanks!

    Monday, August 20, 2012 11:36 PM
  • This solution worked perfectly for me.  Thank you!!
    Tuesday, August 21, 2012 5:58 PM
  • Running with highest privleges resolved the issue for me too.  I was about to rip out all my hair - thanks for the help.

    Ben Whitehill

    Tuesday, September 11, 2012 8:19 PM
  • #2 seems to have fixed it for me -- I already had everything else setup as noted.  Thank you very much.

    I second that

    Monday, September 17, 2012 7:01 PM
  • 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.
    Wednesday, October 3, 2012 9:54 PM
  • 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!
    Thursday, October 4, 2012 2:54 PM
  • 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!)
    Thursday, October 11, 2012 7:35 PM
  • 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.

    Thursday, October 25, 2012 11:22 AM
  • This worked for me as well.
    Friday, October 26, 2012 4:11 PM
  • Batch files aren't supported (*.bat)

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

    good luck - msfsgl ;)

    Wednesday, October 31, 2012 8:55 PM
  • 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 2, 2012 7:05 AM
    Friday, November 2, 2012 7:04 AM
  • omg!!! this worked for me! I was loosing faith... 
    Tuesday, November 6, 2012 6:08 AM
  • 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..


    People are always promising the apocalypse. They never deliver.

    Thursday, November 8, 2012 10:06 PM
  • 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.

    Wednesday, November 28, 2012 5:10 PM
  • 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?

    Monday, December 3, 2012 9:34 AM
  • 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

    Friday, January 4, 2013 3:46 PM
  • 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 :-(


    Thursday, May 2, 2013 2:51 AM
  • 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

    Friday, June 14, 2013 2:40 AM
  • 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
    Saturday, June 29, 2013 7:28 AM
  • 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).


    "All things are possible, but not all things are permissible"


    Thursday, July 11, 2013 6:15 PM
  • 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
    Monday, July 22, 2013 9:06 PM
  • 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. 


    Craig Brand

    Wednesday, September 11, 2013 9:53 AM
  • 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!

    Friday, September 13, 2013 12:28 PM
  • This worked for me: Server 2008 R2 x64

    lb

    Thursday, September 19, 2013 6:45 PM
  • 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!

    Wednesday, December 4, 2013 6:18 AM
  • After trying just about everything else this was the only one that worked.  

    Wade Wolverton

    Wednesday, December 18, 2013 9:04 PM
  • 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.
    Sunday, December 22, 2013 6:45 AM
  • 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

    Friday, December 27, 2013 12:57 PM
  • Hi, Great!

    It solved my problem.

    Regards.

    Friday, January 3, 2014 10:29 AM
  • Thank you very much. That tip solve my problem!.
    Monday, January 13, 2014 6:33 PM
  • 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

    Wednesday, January 22, 2014 3:53 PM
  • 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.

    Thursday, February 6, 2014 3:52 PM
  • The was a life saver.... Thank you!
    Tuesday, March 4, 2014 5:46 PM
  • 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!
    Saturday, April 12, 2014 3:42 PM
  • 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.

    Thursday, April 17, 2014 3:07 PM
  • 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!!
    Wednesday, May 7, 2014 9:44 PM
  • Thanks... I was facing the same trouble and your solution above solved it for me.. 
    Wednesday, June 11, 2014 9:09 AM
  • I had this same issue.  Adding the folder path to the batch file in the Start In field fixed the problem.
    Tuesday, June 24, 2014 1:57 PM
  • You legend!!! that was it!
    Tuesday, July 1, 2014 3:47 AM
  • Yes!  Thank you for this tip.  Makes sense... now.
    Thursday, July 10, 2014 5:23 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.

     

    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
    Sunday, July 13, 2014 11:44 AM
  • 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??

    Monday, September 15, 2014 12:09 PM
  • 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

    Thursday, November 13, 2014 11:47 PM
  • 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.  

    Wednesday, November 26, 2014 3:26 AM
  • 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
    Wednesday, December 10, 2014 5:03 PM
  • 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!



    Monday, January 19, 2015 1:23 PM
  • Thanks Nick, that worked for me!
    Friday, February 13, 2015 11:33 PM
  • 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
    Wednesday, February 25, 2015 9:17 AM
  • 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\"

    Thursday, February 26, 2015 10:43 AM
  • 7 years later and still a problem.  running the task as the local pc administrator worked !!!!!  Thanks to this forum !!!!!
    • Marked as answer by Alex Lv Thursday, April 16, 2015 1:37 AM
    Tuesday, March 3, 2015 4:13 PM
  • 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.

    Thursday, April 16, 2015 11:45 AM
  • 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.
    Monday, April 27, 2015 5:02 PM
  • 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??
    Wednesday, April 29, 2015 7:37 PM
  • 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!
    Friday, May 1, 2015 4:07 PM
  • 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.

    Thursday, May 7, 2015 7:53 PM
  • 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.
    Thursday, May 21, 2015 8:33 PM
  • That worked for me, thanks!
    Tuesday, June 9, 2015 2:24 PM
  • 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 !!!!

    Wednesday, June 10, 2015 4:57 AM
  • Just to say that following the steps by Brian, and in particular step 2, did the trick for me.

    Thanks

    Nino

    Friday, June 19, 2015 7:46 AM
  • This worked for me, thanks..

    Gerald Lapalme

    Tuesday, June 23, 2015 2:48 PM
  • 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!
    Thanks a lot Brian! After configuring the path of the bat file in the "start in (optional)" field, the task scheduler was able to execute the bat! The "Full Access" was already granted.
    Thursday, July 9, 2015 10:37 PM
  • yep, same happened to me, I also added the "Log on as a batch job" local security policy since Im running it under a local system account. It works now! thx


    Friday, September 4, 2015 7:22 PM
  • Dear JohnGaunt thank you for share the information. I was hours trying several forum alternatives without sucess in my 2008 Server R2. After rename my bat files with less than 15 characters, all the process started to run fine! Thank you!

    Fabio Brazil

    Monday, September 7, 2015 2:28 PM
  • Such a silly simple thing and YES that did work for me

    thank you

    Monday, September 21, 2015 2:01 PM
  •  Administrators (a group) is the key.  I have tried every possible use case and the only way it worked for me is when i selected the Admin group instead of the Admin user.
    • Proposed as answer by moxima1977 Wednesday, June 8, 2016 2:38 PM
    Thursday, October 29, 2015 11:07 PM
  • Setting the "start in (optional)" field also worked for me (Windows Server 2012).

    SQL Server, its a gas!

    Wednesday, November 25, 2015 12:47 AM
  • I have the similar problem, so I came here.

    My system is Windows 10 64bit.

    I have two "same" task, but one of them doesn't run the programe.

    Finally, I found one's state is Ready, another one's is Running, so I terminate the Running one by right click, then it works fine.

    Hope this will be of help.

    Tuesday, December 22, 2015 4:55 AM
  • Thanks "Bnatutowa", now my batch file is running fine. 

    I just added the path in 'Start In' field where my .bat file is placed.

    Now it is running fine.

    Thursday, January 21, 2016 7:19 AM
  • Works for me like a champ!!!! Thx
    Wednesday, June 8, 2016 2:37 PM
  •  Administrators (a group) is the key.  I have tried every possible use case and the only way it worked for me is when i selected the Admin group instead of the Admin user.

    This seems to have done the trick for me to when I choose this manually in the Windows Task Scheduler interface

    Two questions

    1. Any ideas on WHY this works we a user who is part of the group ie Administrator does not work ?

    2. How do I pass the group to RegisterTaskDefiition via COM. I've tried a few things and cannot get it to work

    This page is a bit unclear on how one should do it
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa382577%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

    Thanks

    PS i'm giving Task Sch an exe to run and am not havign an problems with 15 plus char names or the need to create those empty desktop folders. This admin group thing is what is making it work for me

    Tuesday, July 19, 2016 4:01 PM
  • I like to disable all non-MS Services and Startups before I do updates, or install software.

    I have been doing that through msconfig / Services, and CCleaner / Tools / Startup.

    Unfortunately, these two ways do not allow me to disable some things in Startup (Notepad++, Firefox URL to Y-Mail, Natural Reader), or that have put themselves into the Task Scheduler (Avast, Crystal Disk Info)

    So, I thought - What if I put all of my Startups (or as many as possible) into a BAT file, and then not use the Startup folder - because disabling the BAT file, by renaming it with a .txt extension, would disable them.

    I figured out how to do it.  Below is all you have to type in under each tab, and what's there by default.

    This is the short version, with some info on how to use quotes.

    For the long version - to give credit where credit is due, other things I observed, and a couple of questions - I have put it in this text file for download on my Google Docs: https://goo.gl/zrZtSd

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

    GENERAL
    Name:  Startup
    Author:  Your Admin account name (you don't have to add it anywhere, like User Rights Assignment / Log on as batch job)
    [dot] Run only when user is logged on
    [check] Run with highest privileges
    Configure for:  Windows Vista, Windows Server 2008

    TRIGGERS
    At logon . . . Details:  At log on of any user . . . THIS IS THE FIX
    [dot] Any user
    [check] Activate
    [check] Enabled

    CONDITIONS - no changes to default
    SETTINGS - no changes to default
    HISTORY - no changes to default

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

    ACTIONS
    Start a program
    Program/script:  "C:\Windows\System32\cmd.exe" . . . DON'T RUN THE BAT FILE DIRECTLY

    . . . . . . .

    I'll start with how I'd like to use it:
    My BAT file is in . . . "D:\1\01\1 backup\a  Startup\a  Startup.bat"

    There are two spaces in a folder name, and two spaces in the BAT file name.
    The BAT file is four levels down, and none of the folders have been modified to "Full permissions."
    The BAT file has not been modified to "Full permissions."
    From some previous issue, I recall that you have to put quotes around a string when there are spaces.
    I see that "where to use quotes" is the issue.

    . . . . . . .

    I see that you have to use quotes this way in:
    Add arguments (optional):  /C "a  Startup.bat"
    That make sense, the /C switch is separate from the target.
    /C . . . "Carries out the command specified by string and then terminates"

    . . . . . . .

    But, do not use any quotes in:
    Start in (optional):  D:\1\01\1 backup\a  Startup
    I see that the ending "\" is not necessary.
    It seems like it must automatically put in "hidden quotes" around the path.
    As I understand it, specifying the "Start in" folder is not absolutely necessary.
    You're just helping cmd.exe to find the file.
    If not specified, it will scan everywhere, and eventually find it, very quickly.
    Specifying the "Start in" folder just saves a couple of micro-seconds.

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

    PROBLEMS OBSERVED AFTER RUNNING THIS STARTUP.BAT

    There is no Sys Tray icon for Power Menu, although, I see that it is running in Task Manager
    Natural Reader chokes
    Firefox is either really slow, or freezes
    I see a lot more "Not Responding"
    My whole computer seems much less responsive, compared to if I put the programs in the Startup folder

    I get the same results, if I put the BAT file in the root . . . "C:\Startup"

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

    WOULD IT HELP IF I SIMPLIFIED THIS?

    I renamed the file to just "Startup.bat"
    I put the BAT file in Sys32, which is where cmd.exe resides, so it will find it easily . . . "C:\Windows\System32\Startup.bat"
    Add arguments (optional):  /C Startup.bat . . . no quotes are necessary now
    Start in (optional):  Nothing is required here now.  I see that it will still find it, though, even if you left it in "C:\Startup"

    I give "Full Control" to the BAT file itself - just for my Admin User account.
    I notice that if I change the perms outside of the Sys32 folder, I have to re-do them when I put it in the Sys32 folder.

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

    RESULTS

    I get the Power Menu icon now - "Full Control" to the Admin User account in the BAT file must have done that . . . but the computer is still much less responsive than normal.

    I give "Full Control" to the BAT file itself, for ALL APPLICATION PACKAGES (this is not there, if it's not in the Sys32 folder) . . . No improvement seen

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

    CONCLUSION

    I can get the programs to launch, but it looks like there's something about launching them from the "Startup" folder that makes the computer run better, so that's where I'll leave them.

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

    Here's my Startup.bat . . . You use a text editor, and just rename it to Startup.bat.txt to edit it, and then back again, for it to work:

    . . . . . . .

    START "Power Menu" "C:\Program Files\PowerMenu\PowerMenu.exe"

    START "Natural Reader" "C:\Program Files\naturalsoft\naturalreader9\NaturalReader9.exe"

    START "Scratch" "C:\Notepad++\notepad++.exe" "D:\1\01\3 xls\scratch.txt"

    START "Sea Monkey Mail" "C:\Program Files\SeaMonkey\seamonkey.exe" -mail

    REM Put the URL in quotes
    START "Y-Mail Basic" "C:\Program Files\Mozilla Firefox\firefox.exe" "https://us-mg5.mail.yahoo.com/neo/b/launch"

    . . . . . . .

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Wednesday, August 3, 2016 9:04 PM
  • For a task schedule to run if log on or not. choose local administrators group not administrator user. This work for me on five servers.
    Thursday, August 4, 2016 7:22 PM
  • I see that the "Startup" folder does have different / extra permission security settings, compared to a regular folder.

    Here's what I found, in two formats, on my Google Docs . . . a screenshot, and the xls file I did:

    f-secur.jpg . . . https://goo.gl/gJ7LTe

    f-secur.xlsx . . . https://goo.gl/xnDRbX

    Something about the extra permission settings must make the computer run better, when these programs are booted up.
    Friday, August 5, 2016 5:11 PM
  • I haven't tried it, but this looks like it would be the most effective, easiest way to hide a BAT file that you're running:

    Run a batch file in a completely hidden way - Super User . . . To hide batch files or command files or any files.... Use Windows XP built in IExpress.exe utility [IExpress 2.0 is in both Win 8.1 and Win 10] to build an .EXE out of the batch file. When using IExpress, make sure you check the "run hidden" option and check mark all the boxes about not showing anything. After you create your .exe place it in whatever run command folder you choose, and you will never see it come up . . . http://superuser.com/questions/62525/run-a-batch-file-in-a-completely-hidden-way

    Other options would be to run "minimized," and possibly make use of the "exit" switch.

    It's not too hard to see how to code the command lines.  Here are some resources I looked at, in a text file on my Google Docs:

    BAT commands.txt . . . https://goo.gl/e0GV6f

    Here's a practice BAT file I did:

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

    REM The order of the commands makes a difference.  Color has to go before /K
    REM Separate switches with &
    REM I see that it auto-clears the screen, so no need for CLS, or quotes
    REM To see the Directory of the Root drive, and then the Directory, in alpha order
    REM
    REM
    REM START CMD.EXE /T:FC /K CD\
    REM START CMD.EXE /T:FC /K "CD\ & CLS"
    REM START CMD.EXE /T:FC /K "CD\ & DIR /O"
    REM
    REM
    REM I thought I had to use ECHO to do this, but all you need is a right arrow >
    REM
    REM
    START CMD.EXE /T:FC /K "CD\ & D: & DIR /O > "D:\download\directory of D.txt" & DIR /O"
    REM
    REM
    REM /T:FC . . . change it to white background with red text
    REM /K . . . leave the DOS window open
    REM "CD\ & . . . go to the root - this step is not necessary here, but shown
    REM D: & . . . switch to D:
    REM DIR /O . . . show the Directory in alpha order
    REM > "D:\download\directory of D.txt" & . . . send contents of the Directory to a text file
    REM I can't send this text file to C: from the BAT file due to UAC protection
    REM I believe I could, if I put it in the Task Scheduler, and gave it highest privileges
    REM DIR /O" . . . show the Directory in alpha order in the DOS window
    Friday, August 5, 2016 5:13 PM
  • I figured it out (settings are in the next post).  Task Scheduler, Version 1.0 has some peculiarities.

    It's like they simplified getting the job done, and didn't bother to tell you about the slightly different syntax it uses, from that of cmd.exe

    *****************************************************************************************

    Comments on the TS GUI under "Actions":
    a.) the cell sizes are too short to be useful
    b.) the cell positions are misleading, as to their importance
    c.) the cell text description is misleading, and not useful

    Why don't they give you a "heads up" on the syntax used, and useful examples right there for you to model?

    Here is my sequence of thought, and what happened:

    *****************************************************************************************

    KEY POINTS:

    The Startup folder has extra perms compared to regular folders? . . . Wait, now I'm thinking . . .
    What if I put my BAT file, with my Startup programs, in the Startup folder?  [this was a good idea]

    ERRORS SEEN . . . I think the following errors were all due to the use of quotes, which I figure out later.
    [and un-intentional, dual launches of cmd.exe from "Program/script" and "Additional arguments"]

    I see that I have to edit "Startup.bat" "outside" of "Startup," and then put it back there.

    Crystal Disk won't work in the Startup.bat, even with the .bat file in the Startup folder, which has all perms,
    and all perms being checked on the .exe

    Instead of putting the full file path in the "Program/script" text box, use the "Start in" field to put the folder that the .bat file is actually in . . . http://www.blogfodder.co.uk/2012/4/20/win-2008-task-scheduler-with-return-code-1-0x1
    . . . This works partially. If there is no output from the batch/script, then there is always 0x1. To have nice 0x0 result, try to add at the end of your working batch / script this:
    EXIT 0
    . . . Of course, you can use different exit codes in your batch to pass back to Task Scheduler, too.

    It appears that no "\" is required at the end for a folder path . . . http://www.lagmonster.org/docs/DOS7/z-path.html

    /B . . . Specifies to exit the current batch script instead of CMD.EXE. If executed from outside a batch script, it will quit CMD.EXE . . . http://www.computerhope.com/exithlp.htm . . . DOES LOWER CASE b WORK?  YES

    The most straightforward way to explain how to use Task Scheduler is:
    Determine the correct DOS coding externally.
    Programs:  Put in just the executable.  Only use quotes if there's a switch.
    Add arguments:  Don't use this field.  It's unclear how the commands are interpreted.
    Start in:  Put in the path with no \ at the end

    WHAT YOU WANT IN THE THREE ARGUMENT CELLS:
    - - - - -
    "Startup.bat /B"
    . . . < < < nothing in here
    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
    - - - - -
    [NO QUOTES OR "\" AT THE END IS NECESSARY IN THE "START IN"]
    LAST RUN RESULT - The operation was canceled by the user. (0x800704C7)

    Task Scheduler / History tab for Startup.bat / I see that it takes six steps
    I THINK THIS IS LESS THAN IT WAS BEFORE.  I DON'T SEE ANY INDICATION OF AN ERROR.

    Administrative Tools / Event Viewer / Applications and Services Logs / Microsoft / Windows / TaskScheduler / Operational (right-click to Enable this)
    THERE'S A LOT IN HERE, BUT I DON'T SEE ANY ERRORS (RED CIRCLE WITH AN EXCLAMATION POINT)

    Windows, disable prompt, "How do you want to open this type of file? (bat)"
    TS / Conditions tab / [check] Start the task only if the computer is idle for:  1 min
    WORKED . . . MAYBE, IN REALITY, IT LOADS SOONER THAN A MINUTE, IF POSSIBLE . . . NO SLOW DOWN IN LOAD UP NOTICED
    I SEE THAT I COULD DELAY IT FOR 30 SECONDS UNDER "AT LOGON" - TRY THAT . . .
    IT GAVE ME THE SCREEN ASKING HOW TO RUN A BAT FILE . . . PUT IT BACK TO ONE MINUTE, UNDER CONDITIONS
    30 minutes after the computer has been on, and I'm not doing anything with .bat files, it asks how I want to launch a bat file
    Why is it asking me what program to use on a .bat file?  LOL
    It's not that bad.  It doesn't happen that frequently.  If I just click the screen, it disappears.

    Is my "Start in" path actually being use?
    I put a test "Startup.bat" here, which would have brought up ipconfig.  It did not launch it.
    C:\ProgramData\Microsoft\Windows\Start Menu\Programs . . . "Startup.bat /b"
    It did launch this "Startup.bat" from this path, as expected
    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp . . . "Startup.bat /b"

    Does Startup.bat work, if the other software choices are made?
    Windows 8.1 . . . Works, this is the OS I have, so I'll leave it on this
    Windows 7, Windows Server 2008 R2 . . . WORKS
    Windows Vista, Windows Server 2008 . . . WORKS
    Monday, August 8, 2016 11:24 PM
  • Settings to make the BAT file run - This is how I have automated my "Startup" programs:

    Please be sure to click and give me points on this post - I'm curious to see that you will get positive results with these settings!

    *****************************************************************************************

    GENERAL
    Name:  Startup
    Author:  Your Admin account name (you don't have to add it anywhere, like User Rights Assignment / Log on as batch job)
    [dot] Run only when user is logged on
    [check] Run with highest privileges
    Configure for:  Windows 8.1 (this is the OS I'm running, so I'll use that, but, I see that any of these work)

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

    TRIGGERS
    At logon . . . (NOT "At startup") . . . I looked at how Crystal Disk Info was getting the job done
    [dot] Any user
    [check] Activate
    [check] Enabled

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

    ACTIONS

    Action:  Start a program

    Program/script:  "Startup.bat /B"

    Add arguments (optional): . . . nothing goes in here

    Start in (optional):  C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

    - - - - -

    Use quotes around your bat file name, and the /B switch.

    Put "Startup.bat" (example below) in your Startup folder.  I use Classic Shell, which makes it easy to find everything in Win 8.1

    If you use quotes around the "Start in" path, it will fail.

    No backslash "\" is required at the end of the "Start in" path.  You can put one there, though, if you want to, cmd.exe knows how to handle it.  There's a whole story behind the back "\" and forward "/" slashes.

    "Last Run Result" will be - "The operation was canceled by the user. (0x800704C7)" . . . due to the /B switch (?) . . . that makes sense.

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

    CONDITIONS
    [check] Start the task only if the computer is idle for [1 minute]
    . . . This gives Windows time to load, and then, it will not ask you how to run a BAT file, immediately

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

    SETTINGS - no changes to default
    HISTORY - no changes to default

    *****************************************************************************************

    Here are the notes I took to figure this out, on my Google Docs.  35 screens . . . https://goo.gl/k8w8ed

    *****************************************************************************************

    This is my "Startup.bat" file:

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

    START "" "C:\Program Files\PowerMenu\PowerMenu.exe"

    START "" "C:\Notepad++\notepad++.exe" "D:\1\01\3 xls\scratch.txt"

    START "" "C:\Program Files\naturalsoft\naturalreader9\NaturalReader9.exe"

    START "" "C:\Program Files\SeaMonkey\seamonkey.exe" -mail

    START "" "C:\Program Files\Mozilla Firefox\firefox.exe" "https://us-mg5.mail.yahoo.com/neo/b/launch"

    EXIT 0

    *****************************************************************************************


    • Edited by mb1280 Tuesday, August 9, 2016 7:48 PM I forgot to check to receive notification of a reply, no way to do that now ic
    Monday, August 8, 2016 11:32 PM
  • Sample .bat file - ipconfig and Directory of C.bat

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

    @ECHO OFF

    REM Put @ECHO OFF at the top, to hide the first line of text, and only see what you want.
    REM Normally a command is executed and takes effect from the next line onwards.
    REM @ is a rare example of a command that takes effect immediately.

    REM This puts a title at the top of the DOS window
    TITLE ipconfig and directory of C:

    REM WHAT THIS BAT FILE WILL DO:
    REM go to C:, and look at ipconfig, then look at the directory of C:

    REM 5 blank lines
    ECHO:
    ECHO:
    ECHO:
    ECHO:
    ECHO:

    C:

    cd\

    ipconfig /all

    PAUSE

    REM 5 blank lines
    ECHO:
    ECHO:
    ECHO:
    ECHO:
    ECHO:

    DIR

    PAUSE
    Monday, August 8, 2016 11:36 PM
  • I figured it out.  See my Settings post at the bottom!
    Tuesday, August 9, 2016 12:40 PM
  • I see that when the "Trigger" is set for "At startup" . . . it will work if the BAT file has been placed in your "Startup" folder

    Within this "Trigger" window, I see that you can also:
    [check] Delay task for . . . 30 seconds . . . or 1 minute - select 1 minute
    . . . But the window asking about how to run a BAT file comes up after 1 minute . . . this is after the initial boot-up
    . . . . . . It eventually disappears on its own, I would describe this as being an "annoyance"
    . . . . . . After the second bootup, does it remember?  No, it still comes up after 1 minute
    . . . It seems like TS was better the other way - maybe "At logon" with the Condition of 1 minute, gives it slightly more time, so that the OS knows what to do with a BAT file
    . . . What if I [check] "Activate" under the Trigger's "Advanced settings" - Crystal Disk Info had that checked, maybe it does something.
    . . . . . . No, the window came back up
    . . . If I set the Delay for 30 minutes, will it run the BAT file anyway, after the OS has been loaded, because it doesn't have anything else to do?
    . . . . . . Yes, how did I know that it would do this?  Maybe from past experience, seeing that values you put in are not necessarily going to be observed
    . . . . . . So then, what's the purpose of saying 30 minutes, if it runs the BAT file right away?
    . . . . . . This is the age of science and reason, where facts and numbers are supposed to mean something - but they don't here - Why?
    . . . . . . Does the "30 minute" delay keep the window from coming up after a minute?
    . . . . . . I don't see it . . . So, that's good . . . Maybe the Delay of 30 minutes keeps it suppressed
    [check] Enabled (default)

    So then, under the "Conditions" tab, I will:
    [un-check] Start the task only if the computer is idle for . . . 1 minute

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

    Triggers . . . https://technet.microsoft.com/en-us/library/cc748841(v=ws.11).aspx

    At startup . . . This trigger causes the task to run when the computer starts up. The only settings for this trigger are the advanced settings described in the Advanced Settings section below.

    Delay task for or Delay task for up to (random delay) : This setting allows you to specify an amount of time to delay the task from running, after the task is triggered. If you are using a time-based trigger ( On a schedule ), then the delay time will be a random time between the time the task is triggered and the time specified in this setting. If a task is scheduled to be triggered at 1:00 pm, and the Delay task for up to (random delay) setting is set to 5 minutes, then the task will run sometime between 1:00 pm and 1:05 pm.
    . . . The task is triggered, but is not delayed from running . . . It looks like the "30 minute Delay" keeps the window from popping up, though
    . . . What if I set the Delay to the maximum value of 1 day?  Of course, the BAT file runs right away . . .
    . . . Does the window show up after 1 minute?  No

    Activate : This setting allows you to set a date and time to activate the trigger. Once a trigger is activated, the trigger can cause the task to run. The time is relative to the time zone that is set on the computer that runs the task. Check the Universal check box to make the time relative to Coordinated Universal Time (UTC) instead of the time zone that is set on the computer that runs the task. Use the Universal setting when you want to coordinate a set of tasks to activate simultaneously in multiple time zones.
    . . . Activate has been checked.  Is the date and time to activate the trigger when the computer boots up?
    . . . . . . No, I see that it retains the date and time that it got from the first boot-up / Activation
    . . . I [un-check] Activate . . . Programs loaded up without it . . . I will keep "Activate" un-checked
    . . . The window asking how to open a BAT file has not appeared
    . . .
    . . . What if I un-check Delay for 1 day?
    . . . . . . It was un-checked.  How did that happen?
    . . . I do a Restart with it un-checked.  Do I get the window?
    . . . . . . No, it's running how you want it to now.  No idea why.

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

    NEW SETTINGS

    TRIGGERS
    At startup . . . it will work if the BAT file has been placed in your "Startup" folder
    [un-check] Delay task for:
    [un-check] Activate
    [check] Enabled

    CONDITIONS
    [un-check] Start the task only if the computer is idle for . . . 1 minute
    Tuesday, August 9, 2016 7:44 PM

  • New discovery:  NO /B or quotes are needed in the Program/script

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

    Somehow, from my test runs, I thought that I needed the /B switch in "Startup.bat /B"

    I asked if there was a resource that listed all of the possible switches that you can use on a bat file . . . .BAT file - What are all of the possible switches? . . . http://superuser.com/questions/1113878/bat-file-what-are-all-of-the-possible-switches

    I want to see it /S or /Q was there, something like that, to run silently or quietly.

    I learned:

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

    Batch files themselves do not have any inherent switches.

    They can accept parameters that can be passed into the batch file to be used as switches (or other things) as needed by the commands within the batch, but those are defined/implimented by the author of the batch script.

    The switch you're speaking of (/B) is for the Exit command. If you want a list of switches for Exit (or practically any command prompt command), open a command prompt and type exit /?.

    https://en.wikibooks.org/wiki/Windows_Batch_Scripting#Switches

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

    I was going to explain that although I had "EXIT 0" at the end of my BAT file, it needed the /B switch, in order to close the DOS window.

    I decided to double-check that, and found that I don't need the /B switch . . . wow!

    ACTIONS
    Program/script:  "Startup.bat" . . . works
    Program/script:  Startup.bat . . . works also - without the quotes - I'll change it to this, it's simpler

    . . . so, to re-state the current settings I'm using:

    *****************************************************************************************

    GENERAL
    Name:  Startup
    Author:  Your Admin account name (you don't have to add it anywhere, like User Rights Assignment / Log on as batch job)
    [dot] Run only when user is logged on
    [check] Run with highest privileges
    Configure for:  Windows 8.1 (this is the OS I'm running, so I'll use that, but, I see that any of these work)

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

    TRIGGERS
    At startup
    [check] Enabled

    . . . and, make sure that you put your BAT file in the Startup folder, so it has those permissions

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

    ACTIONS

    Action:  Start a program

    Program/script:  Startup.bat

    Add arguments (optional): . . . nothing goes in here

    Start in (optional):  C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

    - - - - -

    CONDITIONS - no changes to default
    SETTINGS - no changes to default
    HISTORY - no changes to default

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

    In my Startup.bat at the end, I put:  EXIT 0 . . . The "Last Run Result" will be - "The operation was canceled by the user. (0x800704C7)" . . . that makes sense.

    How does putting "EXIT 0" at the end of your bat file work?

    https://en.wikibooks.org/wiki/Windows_Batch_Scripting#Error_level

    Error level

    Commands usually set error level at the end of their execution. In Windows NT and later, it is a 32-bit signed integer; in MS DOS, it used to be an integer from 0 to 255. Keywords: return code, exit code, exit status.

    The conventional meaning of the error level:

    0 - success
    not 0 - failure . . . [and, I see the "Last Run Result" above]
    The error levels being set are usually positive.
    If the command does not distinguish various kinds of failure, the error level on failure is usually 1.

    *****************************************************************************************
    Tuesday, August 16, 2016 4:21 PM
  • 1. Any ideas on WHY this works we a user who is part of the group ie Administrator does not work ?

    If it's not a bug, no.

    Does anyone know if this continues in Server 2016?

    Tuesday, September 13, 2016 4:51 AM
  • This issue has driven me mad several times when moving to a new server, I import all of my old Task Scheduler jobs and they don't appear to run any of the underlying batch jobs or whatever they're meant to do.

    At first you think it's permissions, or something to do with the user running them etc, but try this fix instead.

    Perform a regedit on this key
     HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems\Windows

    You will have a value like this one:

    %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,5120 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=sxssrv,4 ProfileControl=Off MaxRequestThreads=16

    The fix -

    Change the third value in the SharedSection (5120) to 768.  Restart your server and your jobs will now run.

    If you want to read more about what this fix is actually about, see these URLs.  This issue is to do with the desktop heap sizing.

    http://blogs.msdn.com/b/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx
    http://www.danjourno.com/how-to-fix-task-scheduler-error-0xc0000142/
    https://support.microsoft.com/en-us/kb/2102398

    Tuesday, September 20, 2016 8:12 PM
  • I don't care if you posted this ~7 years ago... thank you.
    Also was #2 for me.
    Monday, October 3, 2016 4:40 PM
  • Worked for me, SBS2008 R2. Thank you :)
    Sunday, October 16, 2016 9:16 AM
  • 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?

    Thanks, this worked for me. :D
    Thursday, December 1, 2016 10:59 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

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

     

    OMG!!!

    I have tried all other suggestions with no success.

    Thank you.

    Thursday, February 2, 2017 7:09 AM
  • To execute a batch file through the task scheduler while "Run whether user is logged on or not" is check requires an account which has access to the location that the batch file is in as well as the resources that it accesses.

    Then open "Local Security Policy" and add the account which will be running the task item to the "Log on as a batch job" setting.

    You may also need to check the "Run with highest privileges" settings for it to work.

    When I set all of those my scheduled tasks which use batch files run without problems.

    • Proposed as answer by MakeItTheBest Friday, March 3, 2017 3:10 PM
    Friday, March 3, 2017 2:12 PM