none
task scheduler returns (0x1) code when 'Run whehter user is logged on or not' options selected

    Question

  • I have setup a task using Task Scheduler that I would like to use to launch a batch file at a certain time each day.  The batch file works correctly when launched manually and the task also works correctly when the option 'Run only when user is logged on'.  However, as soon as I mark 'Run whether user is logged on or not' using the Administrator login, the task returns a Last Run Result of (0x1).  This happens when trying to launch the file on demand or when it is scheduled at it's daily time to run.

    From some research I have done, I don't believe I should see the actions of the batch file and the program that it launches when this option is marked, but I know it is not running correctly in the background due to the fact the log files are not generated from the task it is to complete.  I have marked 'Run with highest privileges' and also entered information in the Start in field under Edit Action with no quotes.  The history logs show that the task successfully finished, despite the lack of the Last Run Result code and no log files being generated.  I have also verified the user being added to the Log on as a batch job option and that there are full permissions to the files (all on the local machine).

    Does anyone have any insight to what I could be missing?  If helpful, i could post the history logs as well.

    Thanks!

    Monday, November 21, 2011 10:17 PM

All replies

  • Does the account you're running the task under have the "logon as batch" user right?
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Monday, November 21, 2011 11:18 PM
  • Thanks for the reply - yes, we have set this user up with this user right, but unfortunately to no avail.  I'm starting to think that it may be related to the program that is trying to launch and the process it is trying to run instead of the Task Scheduler after testing some more, so I'm planning to do some more research on that.

     

    Thanks for your response however!

    Tuesday, November 22, 2011 5:00 PM
  • I had a similar issue today when I enabled "Run whether user is logged in or not" on a task that runs overnight. The task was configured to run a batch file with a simple copy command in it. After I enabled "Run with highest privileges", the task ran successfully.

    Also remember that the user account you are using for the task has the privileges necessary for the programs in the batch file to complete successfully; i.e. if a command to copy something to a server is ran with a user account that exists on the local machine, but not on the server you are copying to, the task will fail silently and may or may not report a result. The same will happen if the username on the local machine and the server is the same, but the password is not.

    Friday, January 06, 2012 7:03 PM
  • Is Microsoft ever going to a) publish a fix for this; or b) give a comprehensive solution for it? They seem to ignore it. I have done everything in every forum thread I've found to fix this and nothing works. It's a simple batch job that works with my personal account but no other. It accesses local files and a WinSCP upload. The user is in local administrators. It has batch logon privileges. 

    I've tried running the WinSCP directly with the same results. 0x1.

    Could MS at least explain what return code 1 is? Is that the really useful "unexpected error?" If it's a permissions issue, shouldn't it state that instead of claiming to have finished? Now I have to update this job every time I change my password and I have no idea what will happen if I should leave the firm. 

    This is very poor design and even worse documentation. Support by forum should be illegal.


    G. Steele at Sedgwick

    Wednesday, July 11, 2012 5:36 PM
  • Check your relative paths in the batchfile. If you are using drive letters that points to a network drive. (drive that the is assigned to the user when logged on) then you wont be able to run the task with "Run whether user is logged in or not".

    To use "Run whether user is logged in or not" you need to use UNC paths or point to the physical disk (if local drive).

    Depending on the program executed in the batch file, it is however not always possible to use UNC paths.  

    Agrree that MS has total F..... up the task scheduler. The log feature is just not usable with error codes like 0x1 or 0xFF. There are better 3. part alternatives....

    Wednesday, August 22, 2012 12:25 PM
  • I have found that entering the directory path to the "Start in (optional):" block for where the script originates works for me. If you put in the quotations around the directory, even though there is a space, within the Start in box I find it doesn't work, so you see I didn't put them in. Check out the screenie ..

    • Proposed as answer by Skrigz Monday, October 08, 2012 8:02 PM
    Wednesday, September 12, 2012 11:29 PM
  • I have found that entering the directory path to the "Start in (optional):" block for where the script originates works for me. If you put in the quotations around the directory, even though there is a space, within the Start in box I find it doesn't work, so you see I didn't put them in. Check out the screenie ..

    Thanks worked for me!
    • Proposed as answer by FrankM68 Wednesday, July 31, 2013 9:03 PM
    Monday, October 08, 2012 8:02 PM
  • Thank you - this worked for me too! :D
    Monday, October 22, 2012 3:38 PM
  • But  did not worked for me...


    Алексей.

    Thursday, November 01, 2012 7:31 AM
  • thanks - adding the directories as shown, run with priv's, changed to only run when user is logged on all worked for me.
    Friday, December 14, 2012 9:28 PM
  • That worked for me too

    Thanks

    Wednesday, March 20, 2013 8:43 AM
  • Another thing often forgotten, is to grant explicit directory rights for the execution account. Typically this becomes a problem, if the batch job needs to create a log file or in any other way modify contents of the target folder. 

    Wednesday, March 20, 2013 10:25 AM
  • Thank you!

    Tuesday, June 11, 2013 7:46 AM
  • Thanks for tip, I got it to work finally!

    My variation - just put the file name under 'Program/Script', no quotes and the directory under 'Start in' as described, again no quotes.

    Wednesday, July 31, 2013 9:03 PM
  • I have found that entering the directory path to the "Start in (optional):" block for where the script originates works for me. If you put in the quotations around the directory, even though there is a space, within the Start in box I find it doesn't work, so you see I didn't put them in. Check out the screenie ..

    Thanks worked for me!
    This one also has worked for me. Putting the directory name (without quotes) in the 'Start in' fixed the error. 
    Wednesday, August 07, 2013 4:32 PM
  • Thanks,

    This solved my problem.

    Problem.

    OS: win 7 starter.

    One Batch file with a copy command. This file didn’t work with scheduler  but it works manually.

    One Batch file with a ftp command. This file works fine with the scheduler and manually.

    Solution.

    In the scheduler of the copy bath file: filed in the directory in the start in field.

    Sunday, August 18, 2013 8:53 AM
  • I had this same exact issue.

    I later found out that the script I was using to create the scheduled task didn't copy the file that the scheduled task referenced.  I felt rather silly.

    Thursday, September 19, 2013 5:39 PM
  • I had this issue too but the above techniques didn't work for me. I then worked out that the file name of the script was too long, so once I shortened it - it worked :)

    Hope this helps!

    Cheers

    Steve

    Wednesday, October 30, 2013 2:46 AM
  • Thank you, Worked like a bomb!
    Monday, December 09, 2013 7:32 AM
  • Life saver! Add the directory in "Start in (optional)" fixed my problem!
    Friday, January 10, 2014 11:30 AM
  • In my case, I configured a web server to email me an alert via Task Scheduler when a tester attempted to log in.  I was seeing (0x1) appear in the Task Scheduler results pane.

    On investigation, Exchange 2010 was treating email from this server as spam.

    In the Exchange 2010 Management Console -> Organisation Configuration -> Hub Transport -> Anti-spam -> Content Filtering -> Custom Words -> Allow messages containing these words or phrases: 

    ...I added the title of the email being blocked as a phrase.

    Click "OK"

    Retest from source server.  ...all then worked for me.




    • Edited by lwoody7110 Saturday, January 18, 2014 8:58 AM
    Saturday, January 18, 2014 8:54 AM
  • GMSteel... Did you ever get a resolution to this? I have tried (I think) every supposed answer/solution in this forum and still my task fails with the same (0x1) result.

    Bradford W Brown

    Thursday, March 06, 2014 9:02 PM
  • I have the same issue where I have a Task which runs the Powershell script to Compress a whole bunch of bak & trn files from a local drive to create a RAR file using the locally installed WinRAR application. This process with RAR commandline also ensures deletion of all the files added to the archive.

    Another task scheduled at a later stage picks the created .RAR file and transfers(MOVE - CUT PASTE) across to another server with UNC path reference.

    When I run the script manually as Admin with Powershell, it works fine in both cases, but when attached to the Task Scheduler task, it comes up with the 0x1 error.

    All these options:

    • Run whether user is logged on or not
    • Run with highest privileges
    • Actions -> Edit -> Program/Script : I invoke Powershell and pass the ps1 file as the argument
    • Start in : C:\Windows\System32\WindowsPowerShell\v1.0\
    • task which is for the copying of the file on to the remote folder is run as this user which has Local Admin rights on both the machine it is running on and the remote server as well.

    Any help would be deeply appreciated.


    Kind Regards, Anils

    Sunday, March 09, 2014 8:30 PM
  • ...even added .\<scriptfilename>.ps1 in the additional arguments, and tried to run and the result is still the same 0x1 error!



    Kind Regards, Anils

    Sunday, March 09, 2014 9:41 PM
  • Very useful thread, solved my issues, thanks all.
    Wednesday, April 09, 2014 10:27 AM
  • Verify that you are allowed to run PowerShell scripts - Get-ExecutionPolicy, default is Restricted which doesn't allow custom scripts to run
    Tuesday, April 22, 2014 5:38 PM
  • of all things - When I went back and put a few REM statements in the .bat script for documentation, now the task reports "completed successfully" instead of (0x1) - guess this is just Microsofts hint to document well - go figure - 
    Monday, May 26, 2014 4:18 PM
  • It worked for me, Gracias!
    Wednesday, May 28, 2014 4:06 PM
  • Just FYI, cant explain it. Don't know why, but I re-wrote my scripts that were failing, from scratch... The problem went away.

    Initially the batch files would run manually no problem but would consistently fail through the task scheduler. Out of frustration, I deleted them and re-wrote... suddenly no problem! Go Figure...

    I deleted the old ones so I can not go back and compare. Obviously something was wrong but I could never find it.


    Bradford W Brown

    Wednesday, May 28, 2014 4:57 PM
  • Hii,

    Thanks it's work for me 

    Monday, June 30, 2014 10:16 AM
  • Hi,

    I m facing the same problem in Windows 8.1 task schedular i have tried all the proposed solution mention above but nothing is working for my case.

    In my case i m invoking the task from System account where the folder where the batch script resides has full control of System account.

    The same scenarion i have checked in Windows 7 but it was working fine in that.

    Please advice how to proceed for Windows 8.1.

    -Lisham

    Tuesday, July 08, 2014 1:23 PM
  • In the task scheduler, edit the properties of the action and check you have the correct "start in" folder as that is likely to be an issue, even if the folder is specified in the Program/script field 

    Friday, August 29, 2014 5:28 AM