Scheduled task fails when it automatically runs, works manually

We are having a problem with a scheduled task on a Windows 2012 R2 server.  The schedule task seems to run fine when we run it manually, but the task fails when it runs with a service account automatically.  The service account is part of the local Administrators group, local Backup group and has been granted "Log on as a batch job" permission.  Anything else we should check to ensure this runs automatically every day?

Here is the error from the Event Viewer:

Log Name:      Application
Source:        .NET Runtime
Date:          4/16/2018 3:00:00 AM
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      CNE-UTL01.int.cgg.com
Description:
Application: SDB Billing.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
   at Microsoft.VisualBasic.CompilerServices.Symbols+Container..ctor(System.Object)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(System.Object, System.Type, System.String, System.Object[], System.String[], System.Type[], Boolean[], Boolean)
   at HarmonyBillingUpload.Module1.Main()

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name=".NET Runtime" />
    <EventID Qualifiers="0">1026</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2018-04-16T09:00:00.000000000Z" />
    <EventRecordID>74861</EventRecordID>
    <Channel>Application</Channel>
    <Computer>CNE-UTL01.int.cgg.com</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Application: SDB Billing.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
   at Microsoft.VisualBasic.CompilerServices.Symbols+Container..ctor(System.Object)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(System.Object, System.Type, System.String, System.Object[], System.String[], System.Type[], Boolean[], Boolean)
   at HarmonyBillingUpload.Module1.Main()
</Data>
  </EventData>
</Event>
Christian PalaciosSenior IT Systems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
YOur problem seems to be in your service constructor.
Q1. Could you post your code constructor?
Q2. Is this service using TCP/IP, HTTp? In other word what communication protocls if any are used?
Q3. What is this service trying to do?
Christian PalaciosSenior IT Systems AdministratorAuthor Commented:
Thanks!  I will see if I can get the code.
This isn't a service, it's just an .EXE that runs nightly.  When the user runs the .EXE manually, it works, but not when it is run by the scheduled task.  The application creates some text files, then sends an email.  It then uses FTP to copy a file over.

Does that help?
Thanks,
- Christian
Miguel OzSoftware EngineerCommented:
You may have an issue that the code in your constructor will depend on the user that is running the EXE.
For example, When the user runs the .EXE manually it works because the user is the EXE user an your scheduled task may be running under a different account.

If more help needed , please post username that works, current  scheduled task setup, we need to find out if the users are the same,
Here is an article to get you started:
https://blogs.technet.microsoft.com/askperf/2015/02/18/help-my-scheduled-task-does-not-run/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Christian PalaciosSenior IT Systems AdministratorAuthor Commented:
Thanks!  Reviewing the document helped me figure out I needed to set the Run As setting to "Windows 7 or Windows 2008 R2".
That seemed to fix it and it successfully ran this past weekend.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.