• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 41
  • Last Modified:

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>
0
Christian Palacios
Asked:
Christian Palacios
  • 2
  • 2
1 Solution
 
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?
0
 
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
0
 
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/
0
 
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now