none
Task Scheduler Problem (run whether user is logged on or not)

    Question

  • I'm having a problem with scheduling a task in Windows 7 Home Premium. 

    I have been having problems getting tasks to launch appropriately, so I set up a basic task as a test.  I set it to open Calculator at a specific time.  I then added options one at a time until I got the same failure to launch that I was getting on my previous tasks. 

    The Calculator test task works as long as it is set for "Run only when user is logged on." 

    As soon as I change the option to "Run whether user is logged on or not", the task fails to launch the application.  The task starts (the status says "Running") but Calculator does not start up.  I did not change any other option.  This happens whether "Do not store password" is checked or not. 

    Why would the "Run whether the user is logged on or not" option cause the task to fail?  Is there a way to fix this? 

    Thanks,

    LDL
    Saturday, February 6, 2010 12:41 AM

Answers

  • There is some pertinent info for your issue in the Task Security Context topic in the Scheduler help file...

    Specifically, it says, "...select the radio button labeled Run whether user is logged on or not. If this radio button is selected, tasks will not run interactively.  To make a task run interactively, select the Run only when user is logged on radio button."

    I guess the concept here is that a task requiring a user interface is simply not going to be allowed to present that user interface to a different user (or to someone passing by the computer when no user is logged-on).

    That's probably not the answer you wanted, but it's possible that you don't actually NEED a user interface, and if so your testing methodolgy is a bit flawed.  Instead of trying to bring up Calculator, try making a small batch file that echoes a message into a log file.

    I know I run backup batch files on a schedule, with a command line interface (and output redirected to a file).  It never pops up any kind of window, but it always runs.

    -Noel
    Saturday, February 6, 2010 2:09 AM

All replies

  • There is some pertinent info for your issue in the Task Security Context topic in the Scheduler help file...

    Specifically, it says, "...select the radio button labeled Run whether user is logged on or not. If this radio button is selected, tasks will not run interactively.  To make a task run interactively, select the Run only when user is logged on radio button."

    I guess the concept here is that a task requiring a user interface is simply not going to be allowed to present that user interface to a different user (or to someone passing by the computer when no user is logged-on).

    That's probably not the answer you wanted, but it's possible that you don't actually NEED a user interface, and if so your testing methodolgy is a bit flawed.  Instead of trying to bring up Calculator, try making a small batch file that echoes a message into a log file.

    I know I run backup batch files on a schedule, with a command line interface (and output redirected to a file).  It never pops up any kind of window, but it always runs.

    -Noel
    Saturday, February 6, 2010 2:09 AM
  • I just tried running a batch file, and it didn't run either.  Again, it worked fine when I selected "Run only when user is logged in."

    I should have pointed out that every time I've tried to run my test task, I've still been logged in.  It runs when I'm logged in and the "run only when user is logged in" radio button is selected, but it doesn't run when I'm logged in and the "run whether the user is logged in or not" radio button is selected. 

    Edited to add:  My end goal is to load a few websites, start up my RSS reader, and download a podcast or two about a half hour before I wake up.  I lock my computer at night (and require a password to log on), and I'd like to run these tasks and have them ready to go when I start it back up in the morning.  Is this even possible?
    • Proposed as answer by Andy.Morgan Tuesday, September 20, 2016 11:19 AM
    Saturday, February 6, 2010 2:37 AM
  • That's what you'd expect of an interactive task given the way the documentation is worded.  It says it will not run interactively based on the radio button being selected, even if you're logged in.

    I just tested this (on Windows 7 Ultimate).  I created a simple batch file with the following in it:

    ECHO I ran! I really did! >c:\temp\TestBat.log

    I scheduled it to run one time, using my account, and selected Run whether user is logged on or not.  Then I logged off a couple of minutes before the scheduled time.

    Sure enough, when I watched the folder with another computer through the network, the TestBat.log file was created with the expected contents at the expected time.

    I don't know what to tell you besides "keep trying".

    What status did the scheduler list for the task after it should have run?

    -Noel



    Saturday, February 6, 2010 2:58 AM
  • Hi

    Did you manage to resolve this issue?

    Many thanks

     

    Monday, March 22, 2010 12:35 PM
  • Still looking for answers for this particular issue. I have actually created a scheduled task on a Windows Server 2008 R2  box that kicks off a Powershell script. The script uses the robocopy command to mirror a directory on the server itself with a mapped drive to another machine on the same domain. When I manually start the scheduled task using the "Run only when user is logged on" option I can see the task run interactively and it mirrors the directories as expected. When I change the ST to use the "Run whether user is logged on or not" the script does not get executed. I understand that it will not be interactive if I run it in this manner but I do not understand why it does not run the script that contains the robocopy command. The ST reports that it completed successfully. I am using my domain account to launch the ST; I am an admin on the local server, a domain admin on the domain and I have full read/write/execute to the mapped drive I am copying to.

    Any ideas of what to check/update to get this set-up to work correctly?

    Thanks!!

    Friday, July 2, 2010 5:29 PM
  • To run the task with the option "Run whether user is logged on or not" you have to activate the option "Run with highest privileges". After activating this option the task really run whether the user is logged or not.

    Maybe it is helpful to configure the Actions as following:
    Program/script: C:\Windows\System32\cmd.exe
    Add argumetns (optional) : "/C C:\HelloWorld.bat"

    BR

    Tuesday, July 20, 2010 11:33 AM
  • I've got the same problem with powershell backup command.

    Option option "Run whether user is logged on or not" makes the script doesn't work. But it's job status is OK.

    I tried many different options and methods to run this script. Once I wrote whole script in one long command and scheduled it. Every time there is the same result. I mean no results when option "Run whether user is logged on or not" is on.

    Of course "Run with highest privileges" is on.

    Does anyone know of a solution? Please help!

    BR

    • Proposed as answer by HarishAnil Friday, February 2, 2018 10:19 AM
    Wednesday, December 29, 2010 12:32 PM
  • That's what you'd expect of an interactive task given the way the documentation is worded.  It says it will not run interactively based on the radio button being selected, even if you're logged in.

    I just tested this (on Windows 7 Ultimate).  I created a simple batch file with the following in it:

    ECHO I ran! I really did! >c:\temp\TestBat.log

    I scheduled it to run one time, using my account, and selected Run whether user is logged on or not .  Then I logged off a couple of minutes before the scheduled time.

    Sure enough, when I watched the folder with another computer through the network, the TestBat.log file was created with the expected contents at the expected time.

    I don't know what to tell you besides "keep trying".

    What status did the scheduler list for the task after it should have run?

    -Noel




    I copied your example, and it worked for me as well, but with another task that also calls a batch, which in turn executes an SSIS package, it does not work when it's on "run when user is logged on or not".
    Monday, January 24, 2011 10:35 PM
  • Update: Fixed

    The reason the simple batch works and the more complex does not is because it was referencing a file on a mapped drive, which can have issues in this context.  The fix for me was to use a direct file path reference instead of a mapped drive reference

    more info:

    http://www.networksteve.com/forum/topic.php/Running_Scheduled_Task_using_%22Run_whether_user_is_logged_on_or_n/?TopicId=10304&Posts=0


    Please vote this up because it wasted half an hour of my time!

    • Proposed as answer by Jw-Clt Monday, January 24, 2011 10:40 PM
    Monday, January 24, 2011 10:40 PM
  • Did you get a resolution to this matter?

    I have been trying to run an xcopy command in a bat file to copy files from my local Win 7 hard drive to a shared folder on another Win Vista Business machine.

    The bat file works fine, and it runs fine from task schedule until I select 'Run whether user is logged on or not' option, then it never runs, although the task history seems to think it has.

    So I changed my xcopy command so the destination was to the share path instead of mapped drive, this still didn’t work. My final attempt was to include the user name & password for the destination machine (share) in the path but this also failed.

    Any thoughts?

     

    Friday, April 1, 2011 9:53 AM
  • I also had problems with moving a file from local harddisk to a remote shared folder by a script that runs under scheduler.

    When the scheduler runs, it doesn't know what drives you have maped in your explorer.

    Use the complete network path instead. It worked for me.

        move somefile.txt t:\      This will not work.

    Try:

       move somefile.txt \\192.168.0.2\sharefoler\         Change to your ipaddress and sharefolder.

     

    Good luck!

    // Par

     

    Friday, April 1, 2011 5:36 PM
  • thanks that did the job!
    Monday, April 4, 2011 11:39 AM
  • I had the same problem and a person with the user name "Try*3" has just answerd me and the solution is much simpler than Noel's.

    http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/basic-task-scheduler/7c29bd02-8160-e011-8dfc-68b599b31bf5

    His solution is :

    "I think you have to use the Run only when user is logged on setting as that's all I could ever get to work - just because you have the thing locked does not alter the fact that it's you that is logged on."

    And this solution works even to run the calculator, any program with the account locked. :)

    Thursday, April 7, 2011 5:22 PM
  • LDL707, You have a very good question, It seems like you are having the same problem that I am having.  When you Schedule a Task and Set it to “Run whether user is logged on or not” is checked, is an implied hidden task.

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

    “You can specify that a task should run even if the account under which the task is scheduled to run is not logged on when the task is triggered. To do this, select the radio button labeled Run whether user is logged on or not. If this radio button is selected, tasks will not run interactively. To make a task run interactively, select the Run only when user is logged on radio button.”

    It’s a shame that the Microsoft Support person could not explicitly say that and suggest a possible solution.

    I first experienced this issue about 4 years ago when I was attempting to use test automation software to test applications.  Today, I am still running into the same issue because I need to automate functions of a legacy user interface using .Net UI Automation, scheduled to execute in the middle of the night.  I understand the need to have the desktop secure and a scheduled task running on an unlock desktop would be a risk.  But after years of people talking about this issue I do not understand why the checkbox could not be relabeled and the task “Run whether user is logged on or not, and the desktop locked”.  This would fix many problems and make UI Automation and countless other tasks run as the user expects, while running securely.  It seems like a good percentage of people who use the new UI Automation framework (cool stuff) will be road blocked by this eventually and render countless applications useless.  I have only found one way around this issue.  You must use the radio button, “Run only when user is logged on”, stay logged in all the time, and lock your computer.  Heaven help you if you need to run automation against legacy softer on a hosted server….   Microsoft, we really do need this fixed…

    • Proposed as answer by HarishAnil Friday, February 2, 2018 10:20 AM
    Saturday, June 16, 2012 1:55 AM
  • Hello Everyone,

    Succeeded !!!!!!!

    Even i was struggling with this same Problem to execute a batch via Window scheduler and set the setting to "Run whether the user is logged in or not".

    I tried many time but the batch runs with " Run whether user is logged on" and not with "Run whether user is logged on or not".

    what i discovered is that there was one mapped drive path in my batch file which was not the complete path like y:/AR.qvw actually what i did i changed that map path to the complete path like \\servnamename\d$\AR.qvw and the batch executed successfully with the setting "Run whether user is logged on or not"

    The conclusion is that check the dependency of the script on external resources because when you check this option "Run whether user is logged on or not" It actually conflicts. This my discovery.

    If you have any question write me on arungupta786@gmail.com

    Thanks & Regards,

    Arun

    • Proposed as answer by hadzibeg Friday, September 6, 2013 9:15 AM
    Wednesday, July 18, 2012 12:19 PM
  • Yes Arun, your solution may work if "Run Weather user is logged on or not" radio button is set and you have a batch file, that needs to interact with a file in a given path. 

    However that will still not help in cases where an application like “Calculator” (requiring user like interaction) needs to be displayed and a user is not logged in.  The scheduled task will fail.

    FYI, \\servnamename\d$\AR.qvw is called UNC (universal naming convention) format: \\server\share\file_path

    • Proposed as answer by HarishAnil Friday, February 2, 2018 10:20 AM
    Thursday, July 19, 2012 9:16 PM
  • Dear All,

    Same problem yaar i am totally STUCK.

    http://social.technet.microsoft.com/Forums/en-US/winservergen/thread/1aafa6cd-d972-4e5e-8e5b-1acb0239a942

    Thanks

    Adeel Imtiaz


    Adeel Imtiaz

    Friday, July 20, 2012 12:06 PM
  • Hello guys, got similar problem with Excel. I start a .cmd file which starts bypass all ps1 file which opens up Excel and does Refresh All.

    To get this through i did the following:

    * Create "Desktop" directory in Elevated CMD (This is important!) in 

    C:\Windows\System32\config\systemprofile\Desktop

    C:\Windows\SysWOW64\config\systemprofile\Desktop

    * setup run whether user is logged on or not

    * setup run with highest priviliegies

    * click "Change user or group...", Advanced, Locations: select Whole Active directory, type in starts with the name of your account, then find now and pick the account from search results. This worked for me.

    Twitter: @EdaKucera
    • Edited by EdaKucera Thursday, August 30, 2012 12:50 PM
    • Proposed as answer by smninad Wednesday, November 27, 2013 5:56 PM
    Thursday, August 30, 2012 12:50 PM
  • Creating that Desktop folder worked for me.  I didn't need the "Run with highest privileges".  I have a VBS script that edits a Word document.  The script would run and launch Word, but then would just hang up.  Creating the folder fixed it.  Thanks!

    Wednesday, December 12, 2012 5:57 PM
  • Using a direct file path reference worked perfectly for me.

    I was trying to capture some ping stats running from a .bat file and logging simple results into a .txt file.

    On a Windows 2008 R2 Server I could see the task execute as per the schedule, but nothing was getting written to the log if I used a relative path/filename.

    When I changed to fully qualified filename it just worked :)

    ---BAD---

    echo %date% - %time% "Automated ping test from LOCALSERVER1 TO REMOTESERVER2 & REMOTESERVER3 by USERID" >>pingresults.txt


    ping REMOTESERVER2 >>pingresults.txt

    ping REMOTESERVER3 >>pingresults.txt

    -----------

    ---GOOD----

    echo %date% - %time% "Automated ping test from LOCALSERVER1 TO REMOTESERVER2 & REMOTESERVER3 by USERID" >>C:\Users\USERID\Documents\pingtest\pingresults.txt


    ping REMOTESERVER2 >>C:\Users\USERID\Documents\pingtest\pingresults.txt

    ping REMOTESERVER3 >>C:\Users\USERID\Documents\pingtest\pingresults.txt

    -----------

    Tuesday, January 8, 2013 10:04 AM
  • I regard this as a bug which Microsoft should fix. No excuses.
    Thursday, May 16, 2013 9:28 PM
  • What's a bug?

    That an application can't be run from the scheduler using an arbitrary user ID and just put itself on the console in front of whatever user is there?  Where does it go if no one is logged in?  Or if someone's logged in remotely via RDP?

    I can see it now:

    A military computer, sitting there locked, suddenly pops up a dialog that the janitor, walking by, can interact with...  "Launch?" [Yes] [No]. 

    :D

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    Thursday, May 16, 2013 9:41 PM
  • It is a bug, I believe. I have a few tasks currently running in Windows Server 2003 without any user logging in. But they all have the same problem in Windows Server 2008. 
    • Proposed as answer by BlackBeemer Monday, June 17, 2013 12:07 PM
    Tuesday, June 11, 2013 4:47 PM
  • Hi

    I've also been look to this issue for day's and days. My Task started access and excel and then kept quit.

    UNTILL I Found this solution : 

    * Create "Desktop" directory in Elevated CMD (This is important!) in 

    C:\Windows\System32\config\systemprofile\Desktop

    C:\Windows\SysWOW64\config\systemprofile\Desktop

    After adding these directories it worked !!!

    I read this solution somewhere.. but cannot find the url anymore !!

    Marcel 

    • Proposed as answer by Aocox Wednesday, March 25, 2015 4:49 PM
    Monday, June 17, 2013 12:11 PM
  • I've also been look to this issue for day's and days. My Task started access and excel and then kept quit.

    UNTILL I Found this solution : 

    * Create "Desktop" directory in Elevated CMD (This is important!) in 

    C:\Windows\System32\config\systemprofile\Desktop

    C:\Windows\SysWOW64\config\systemprofile\Desktop

    After adding these directories it worked !!!

    I read this solution somewhere.. but cannot find the url anymore !!

    Marcel 

    Monday, June 17, 2013 12:33 PM
  • thanks this was it. I would never have figured it out since it gave no error whatsoever
    Tuesday, September 10, 2013 3:20 PM
  • This solved the issue for me. Thanks so much! How did you find this solution?

    Also, this is clearly a bug and should be reported as such.

    Thursday, November 14, 2013 3:54 PM
  • Note:  Per my recent observations with Win 8.1, I've seen that environment variables added to the User Variables section for your username are not set even if you've scheduled the task to run with your User Account.  This does indeed seem like a bug.

     

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

    Wednesday, June 18, 2014 4:20 PM
  • I found this.  Credit to original poster.

    Seems to work just fine.

    http://superuser.com/questions/656964/what-user-must-a-scheduled-task-run-as-in-order-to-be-visible-for-all-users

    just tested this and you can select a "group" for the account.

    Pick Run only when user is logged on.

    Click <kbd>Change user or group</kbd> (it says group right there :)

    type in users and click <kbd>Check Names</kbd> and Click Ok

    and you application will run interactively for all users in the group users.


    • Edited by RSMBBDAD Saturday, August 2, 2014 8:57 PM add url
    Saturday, August 2, 2014 8:56 PM
  • Hi,

    The above solution of creating the Desktop directory is not working on Windows server 2012 R2.It just launches the application Window and stops there doesn't proceed further.Are we supposed to do anything more on Windows Server 2012R2

    Monday, October 6, 2014 7:06 AM
  • Yes!!!! Thank You!!
    Wednesday, January 28, 2015 1:30 PM
  • Thans is work for me!!
    Wednesday, March 25, 2015 4:49 PM
  • I tried all sorts of techniques offered on various sites for resolving the issue around 0x1 error when scheduler is set for "Run only when user is logged on." but nothing worked until I finally did the following:   I made sure that the network drive I was referring to in the batch file I was running (.bat) was defined within the batch file before I used it.  eg.:

    net use h: \\wes-bif1\sys
    H:
    cd H:\PUBLIC\Utility\trial
    copy intranet2LIVE.bat intranet2.bat
    exit

    It worked like a charm and I did not have to use full UNC paths.  Best of all, got a 0x0 result !

    Tuesday, July 21, 2015 7:58 AM
  • thank you god
    Thursday, October 29, 2015 5:30 PM
  • Thank you. It works for me.
    Thursday, December 31, 2015 7:45 PM
  • This is an old post but here I am in 2016 with the exact same issue and I'm still not seeing anyone coming up with a proper fix.

    Well that's about to change as I spent yesterday working on this and happened upon a way of getting it to work through trial and error.

    Follow these steps to get it working

    Create a new task and set it to run interactively only.  Make sure you set it to use the specific account for the task.

    Run task and make sure it finishes with an exit code of 0

    Edit task and change to 'run whether the user is logged on or not'

    Save

    Boom!!!  As long as you aren't logged on as the user that will run the task then it should work just fine now.

    Hopefully this helps a few of you guys out there.

    Regards

    Neil Hunter

    Friday, July 1, 2016 1:22 PM
  • 1. create a new task, but select the Configure for: option to be “Windows Server 2003, Windows XP, or Windows 2000” – this will create an XP/2003 fashioned task.

    2. Select the "Run with highest privileges" option.

    This worked for me.

    ref: https://blogs.technet.microsoft.com/askperf/2015/02/18/help-my-scheduled-task-does-not-run/

    • Proposed as answer by ps.pal Thursday, August 31, 2017 4:33 AM
    • Unproposed as answer by ps.pal Thursday, August 31, 2017 6:42 AM
    Monday, August 1, 2016 12:51 PM
  • That's a great find, Morteza12!  Thank you for the post.

    We are often accustomed to think that "newer is better" and don't always think that invoking what looks like "legacy" behavior might actually solve what is really a compatibility problem.

    -Noel


    Detailed how-to in my eBooks:  

    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options
    Not feeling enough love to make one for Windows 10

    Monday, August 8, 2016 12:19 AM
  • This worked for me too. I debug my C# code and realize the code ended at the line

    ExcelFile excelFile = new ExcelFile(directory, filename);

    I check Task Manager and found that it created a Excel process but yet the code exited from that point.

    C:\Windows\System32\config\systemprofile\Desktop
    C:\Windows\SysWOW64\config\systemprofile\Desktop

    Creating the 2 empty folders as mentioned above magically worked! Create both folders even if you are running on x64.

    Friday, August 12, 2016 9:18 AM
  • creating the desktop folders worked for me too!


    Thursday, August 18, 2016 5:04 PM
  • Bingo!  Mine works now.
    Monday, August 29, 2016 2:53 PM
  • Two folders solution worked for me when I set

    'run whether user is logged on or not'

    My application generate Excel file every day, so it must has GUI show up! If I use 'run whether the user is logged on or not', it will not work, until I created those two folders!

    Thanks!

    Monday, September 12, 2016 6:53 PM
  • I do not get an option to 'select Whole Active Directory' -and when I click Advanced the box to select 'Starts With' is grayed out. If you have any advice..please help. this is driving me nuts!

    (I am simply trying to run an app minimized at logon of any user (elevated permissions) -command is 

    <C:\Program Files\Desktopok\DesktopOK.exe> 

    argument <-bg>

    Very simple - but it DOES NOT WORK.

    ALL FILES (paths) ARE LOCAL.

    *this is a test - I would like to run various tasks (.exe's) at startup WITHOUT having to create a separate task for EACH USER+EACH PROGRAM.

    Thanks for your help

    PS the option to create a directory in C:\Windows\System32\config\..\Desktop & C:\Windows\SysWOW64\config..\Desktop did not work. I did NOT get an option in taskschd.msc to select "Whole Active Directory' and the box to select 'Starts With' <username> was grayed out.

    Sunday, September 18, 2016 8:04 PM
  • I agree with BlackBeemer - this is a bug!

    This forum and others demonstrate that - there are clearly countless users who are frustrated by this seemingly useless option. If there are security concerns the option could be locked out on Enterprise versions of Windows or a popup could appear upon selection of that option. Most users (here) are HOME users, who simply want to run a task applicable to all users in their home (or small business). Being unable to do so, they must create a separate task for each individual using the computer. ...a colossal waste of time.

    MICROSOFT - PLEASE FIX THIS. I AM READY TO GO OVER TO THE DARK SIDE (APPLE OR LINUX)...IF YOU DON'T START RESPONDING TO OUR NEEDS AND STOP PUSHING COMMERCIAL UPDATES AT US ...YOU WILL LOSE US. YOU'RE ALREADY WELL ON YOUR WAY THERE. WINDOWS 10 IS  A FLOP COMPARED TO WINDOWS 7....THANKS FOR MOVING US BACKWARD.


    Sunday, September 18, 2016 8:10 PM
  • Specify a security group instead of a user, making sure the user is part of the security group specified.

    this worked like a charm for us.

    Tuesday, September 20, 2016 11:18 AM
  • Hi,

    I am using windows task scheduler to trigger an GUI application to run. I use the create command (include argument /IT so that it can work well with GUI application) to create a task.

    I chose the option "Run whether user is logged on or not", everything works well, I can see it trigger the app to run with a GUI even after reboot. However, it start the app in the background with no GUI if I logout and login again. Do you know why?

    Thanks,

    Tuesday, September 27, 2016 3:11 AM
  • Thanks for this info, still useful after just now encountering your article six years after you wrote it. Here is another question: After my batch ran that used "xcopy", some of the destination folders show the same "Date Modified" as their source, others show the time that my batch ran - why would that be? (why not all one or the other?).
    Tuesday, October 25, 2016 4:48 PM
  • I totally agree with you - MS has lost their everloving minds, on this and quite a few other changes as well.

    Robert Corlin

    Friday, January 27, 2017 11:48 PM
  • What worked for me:  Do not used the mapped drive letters.  Use the UNC rather.  So, I used a batch script to do a nightly backup job, copying files from a server to a NAS.  I do have mapped drives on the server to the NAS, Z: drive in particular.  But in the backup script now has all UNC paths and it just works now.

    Here is the text of my backup script:
    -----
    set currentdate=%date:~10,4%%date:~4,2%%date:~7,2%
    set hour=%time:~0,8%
    echo Backup has started on %currentdate% at %time%. >> \\192.168.1.10\Documents\backup-status.txt
    if exist "\\192.168.1.4\Volume_1\backup\14" rmdir /S /Q "\\192.168.1.4\Volume_1\backup\14"
    if exist "\\192.168.1.4\Volume_1\backup\13" rename "\\192.168.1.4\Volume_1\backup\13" "14"
    if exist "\\192.168.1.4\Volume_1\backup\12" rename "\\192.168.1.4\Volume_1\backup\12" "13"
    if exist "\\192.168.1.4\Volume_1\backup\11" rename "\\192.168.1.4\Volume_1\backup\11" "12"
    if exist "\\192.168.1.4\Volume_1\backup\10" rename "\\192.168.1.4\Volume_1\backup\10" "11"
    if exist "\\192.168.1.4\Volume_1\backup\9" rename "\\192.168.1.4\Volume_1\backup\9" "10"
    if exist "\\192.168.1.4\Volume_1\backup\8" rename "\\192.168.1.4\Volume_1\backup\8" "9"
    if exist "\\192.168.1.4\Volume_1\backup\7" rename "\\192.168.1.4\Volume_1\backup\7" "8"
    if exist "\\192.168.1.4\Volume_1\backup\6" rename "\\192.168.1.4\Volume_1\backup\6" "7"
    if exist "\\192.168.1.4\Volume_1\backup\5" rename "\\192.168.1.4\Volume_1\backup\5" "6"
    if exist "\\192.168.1.4\Volume_1\backup\4" rename "\\192.168.1.4\Volume_1\backup\4" "5"
    if exist "\\192.168.1.4\Volume_1\backup\3" rename "\\192.168.1.4\Volume_1\backup\3" "4"
    if exist "\\192.168.1.4\Volume_1\backup\2" rename "\\192.168.1.4\Volume_1\backup\2" "3"
    if exist "\\192.168.1.4\Volume_1\backup\1" rename "\\192.168.1.4\Volume_1\backup\1" "2"
    mkdir \\192.168.1.4\Volume_1\backup\1
    xcopy /E /I /Q "\\192.168.1.10\Documents" \\192.168.1.4\Volume_1\backup\1\%currentdate%
    set currentdate=%date:~10,4%%date:~4,2%%date:~7,2%
    set hour=%time:~0,8%
    echo Backup has ended on %currentdate% at %time%. >> \\192.168.1.10\Documents\backup-status.txt
    ------

    Those of you that want further info on this script, it simply makes a 14 day rotation of folders on the NAS and copies the live files from the server to the NAS.  
    Those of you that ask why I set the current date again in to the variable at the end of the script is because I start this script at 10pm every night and in case the backup process takes more than 2 hours, I want to know when this script got done and it records it in to the backup-status.txt file.
    192.168.1.4 = NAS
    192.168.1.10 = Server

    Hope this helps everyone.


    • Edited by Chevy96man Wednesday, April 26, 2017 5:16 PM
    Wednesday, April 26, 2017 4:43 PM
  • Hi,

    I am facing similar kind of issue. The link which you gave is not functional anymore. Please have a look at this post one more time and provide your suggestion. I am in need of running automatic interactive tasks in task scheduler and I cannot login to my system all the time. I have Windows 10 Enterprise. I am new to windows and I have used all the combination on the Task scheduler and I am unable to run the app when I am logged off. 

    Use case:  I login to the system via Remote Desktop Connection and if there is scheduled task then it will run when I am in logged in state. If I have not logged in via Remote Desktop Connection then my scheduled task won't run. I have tried the Highest Privileges checkbox as well. On my remote desktop there is no session timeout so, if I leave something open and close the remote desktop connection, it will be open all the time.

    br

    Sunday, May 7, 2017 7:17 AM
  • Hi there, 

    I tried this method but it displayed "Access denied" 

    can someone help me :(

    Monday, May 22, 2017 6:57 AM
  • Have you used "SYSTEM" account? I had a similar issue with a task to turn off the computers at specific time with the option "Run whether user is logged on or not" when I used the SYSTEM account to run the task, it worked.

    Maybe it can solve your problem.

    Regards.

    Thursday, December 14, 2017 1:59 PM
  • URL not found
    • Proposed as answer by MikeKustra Sunday, January 14, 2018 12:11 AM
    • Unproposed as answer by MikeKustra Sunday, January 14, 2018 12:12 AM
    • Proposed as answer by MikeKustra Sunday, January 14, 2018 12:12 AM
    • Unproposed as answer by MikeKustra Sunday, January 14, 2018 12:12 AM
    Tuesday, January 9, 2018 5:32 AM
  • I was also able to correct this issue by creating the folder named 'desktop:

    Create "Desktop" directory in Elevated CMD (This is important!) in 

    C:\Windows\System32\config\systemprofile\Desktop

    Sunday, January 14, 2018 12:13 AM
  • Thank you , this worked!
    Sunday, January 14, 2018 12:15 AM
  • Finally solved this with

    a) "Run only when user is logged on"

    b) Installed LogonExpert Administrator, this allows me to schedule the user to actually BE logged on to run the scheduled task.

    I am not associated in any way with https://www.logonexpert.com/learnmore.html but find it a great solution for this purpose.

    Thursday, February 1, 2018 6:23 PM
  • To Set Run whether user  is logged on not we need to change the group policy "Network access: Do not allow storage of passwords and credentials for network authentication" to Disabled for domain accounts.

    Please refer the below KB article to change the policy and impacts

    https://support.quest.com/kb/135227

    or 

    I have incorporated the changes in the below command using registry which will set as expected.

    The below registry to change the policy

    $RegistryKeyPath="HKLM:\System\CurrentControlSet\Control\Lsa"
    $RegistryKey="disabledomaincreds"
    $value="0"
    Set-ItemProperty -Path "$RegistryKeyPath" -Name $RegistryKey -Value $Value; 
    $TaskName="Test122";
    $Interval="1" #in minutes
    $TaskToRun="c:\windows\system32\calc.exe";
    $NoOfDaystoRun="7";
    $enddate=(Get-Date).AddDays($NoOfDaystoRun) #after 7 days task has to end/expire
    $end=Get-Date $enddate -Format MM/dd/yyyy
    $RunAsUser="domain\admin"
    $RunAsUserPwd="admin123"
    $a=schtasks.exe /create /RU $RunAsUser /RP $RunAsUserPwd /SC DAILY /RI $Interval /TN $TaskName /TR $TaskToRun /ED $end /RL HIGHEST
    If($a -like "*SUCCESS: The scheduled task*")
    {

     echo $True}else{echo $False}



    • Proposed as answer by HarishAnil Friday, February 2, 2018 9:50 AM
    • Edited by HarishAnil Friday, February 2, 2018 9:52 AM
    Friday, February 2, 2018 9:49 AM
  • Do not store will applicable only for System.

    If you are executing a command with domain user , you need to save the credentials on that server so that it will run the task with that credentials. 

    To make it work , you need to change the group plocy settings and then provide run as user name and password it will work.  

    Make sure Highest privilege is select if you select Run whether user is logged on or not. To see process is started or not  go to task manager and search for calc.exe.

    This is the simple task to start calc.exe for every 1 min for 7days. 

    First 4 lines to modify the group policy settins to store password.

    $RegistryKeyPath="HKLM:\System\CurrentControlSet\Control\Lsa"
    $RegistryKey="disabledomaincreds"
    $value="0"
    Set-ItemProperty -Path "$RegistryKeyPath" -Name $RegistryKey -Value $Value; 
    $TaskName="Test122";
    $Interval="1" #in minutes
    $TaskToRun="c:\windows\system32\calc.exe";
    $NoOfDaystoRun="7";
    $enddate=(Get-Date).AddDays($NoOfDaystoRun) #after 7 days task has to end/expire
    $end=Get-Date $enddate -Format MM/dd/yyyy
    $RunAsUser="domain\admin"
    $RunAsUserPwd="admin123"
    $a=schtasks.exe /create /RU $RunAsUser /RP $RunAsUserPwd /SC DAILY /RI $Interval /TN $TaskName /TR $TaskToRun /ED $end /RL HIGHEST
    If($a -like "*SUCCESS: The scheduled task*")
    {

     echo $True}else{echo $False}


    Friday, February 2, 2018 10:18 AM
  • If you are executing a command with domain user , you need to save the credentials on that server so that it will run the task with that credentials. 

    To make it work , you need to change the group plocy settings and then provide run as user name and password it will work.  

    Make sure Highest privilege is select if you select Run whether user is logged on or not. To see process is started or not  go to task manager and search for calc.exe.

    This is the simple task to start calc.exe for every 1 min for 7days. 

    First 4 lines to modify the group policy settins to store password.

    $RegistryKeyPath="HKLM:\System\CurrentControlSet\Control\Lsa"
    $RegistryKey="disabledomaincreds"
    $value="0"
    Set-ItemProperty -Path "$RegistryKeyPath" -Name $RegistryKey -Value $Value; 
    $TaskName="Test122";
    $Interval="1" #in minutes
    $TaskToRun="c:\windows\system32\calc.exe";
    $NoOfDaystoRun="7";
    $enddate=(Get-Date).AddDays($NoOfDaystoRun) #after 7 days task has to end/expire
    $end=Get-Date $enddate -Format MM/dd/yyyy
    $RunAsUser="domain\admin"
    $RunAsUserPwd="admin123"
    $a=schtasks.exe /create /RU $RunAsUser /RP $RunAsUserPwd /SC DAILY /RI $Interval /TN $TaskName /TR $TaskToRun /ED $end /RL HIGHEST
    If($a -like "*SUCCESS: The scheduled task*")
    {

     echo $True}else{echo $False}

    Friday, February 2, 2018 10:19 AM
  • This works for like a charm for me. can you please explain, how would this make difference to running a task
    Monday, March 5, 2018 11:59 AM
  • Thanks! It worked!
    Friday, March 9, 2018 4:28 PM
  • This was the answer for me!  Thank you!
    Tuesday, September 4, 2018 9:31 PM
  • This was my issue.  having the full path resolved it.  
    Tuesday, September 4, 2018 9:33 PM
  • been beating my head against the wall for hours trying to figure this out and finally found this post.

    my batch file had z:\test\test.txt

    I had to change to \\servername\test\test.txt

    once i did that i could check "run whether user is logged on or not" and it would run.  if i just had z:\test\test.txt in my .bat file the only way i could get the task to run was to have the option "run only when logged on" 

    it seems stupid at first but as i think about it..mapped drives occur once a user is logged on, so if a .bat file references z:\test.  Z drive refers to a mapped drive that does not occur till a user is logged on.   so in essence, that is an interactive application.

    Wednesday, September 26, 2018 7:03 PM