locked
.NET Error 1026 on a C# console Application launched from Task Scheduler RRS feed

  • Question

  • Dear all

    I have a c# program that uses MBNApi for managing a Mobile Broadband 4G modem.

    When I run the program interactively with an unprivileged local user, everything goes fine.

    But, When i ran that code from a Scheduled Task (task Scheduler runs under the SYSTEM/S-1-5-18 security context) that is configured to run with the same unprivileged user, as soon as I call a method of the classes exposed by this API, for example "GetInterfaces":

    MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
    IMbnInterfaceManager infMgr =(IMbnInterfaceManager)mbnInfMgr;
    IMbnInterface[] interfaces =(IMbnInterface[])infMgr.GetInterfaces()

    I get the folowing exception:

    Application: xxxx.exe
    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception info: System.UnauthorizedAccessException
       in MbnApi.IMbnInterfaceManager.GetInterfaces()

    Any ideas of the rights I have to set for SYSTEM or the unprivileged account in order to solve the problem

    Wednesday, October 4, 2017 5:29 PM

All replies

  • I had previously published this thread with no luck

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/f2305897-4e90-4267-996d-501a22d348e7/net-error-1026-on-a-c-console-application-launched-from-task-scheduler?forum=csharpgeneral


    • Edited by Pepin Padin Thursday, October 5, 2017 2:37 PM
    Thursday, October 5, 2017 2:33 PM
  • At the c# code I have launched via a Process Object the whoami command in order to get the access token of the unprivileged user in:

    1- The interactive execution (MBN COM Object does not return Access Denied Error)

    2- The exceution from the Scheduled Task under the same unprivileged user account context:

    Process p = new Process();
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.FileName = "cmd";
    p.StartInfo.Arguments = "/c \"whoami /ALL\" > c:\\temp\\whoami.txt"
    p.Start();
    p.WaitForExit();

    The only difference at the access Token that contains all the SIDs of the groups the user belongs to is:

    - In "1", we have "NT AUTHORITY\INTERACTIVE "

    - In "2", we have "NT AUTHORITY\BATCH"

    I changed DCOM security from the root of the computer allowing full rights (Access and Launch+Activation) to "NT AUTHORITY\BATCH", but "GetInterfaces" method generates the same System.UnauthorizedAccessException (HRESULT: 0x80070005 (E_ACCESSDENIED))

    Any ideas?

    Friday, October 6, 2017 3:26 PM
  • Description: The process was terminated due to an unhandled exception.

    So handle the exception with try/catch. The exception in the catch will help you.


    Sam Hobbs
    SimpleSamples.Info

    Sunday, October 8, 2017 9:00 PM
  • Description: The process was terminated due to an unhandled exception.

    So handle the exception with try/catch. The exception in the catch will help you.


    Sam Hobbs
    SimpleSamples.Info


    Sam, details of the exception (what would be recovered at catch) are in this thread and the other referenced thread
    Monday, October 9, 2017 8:08 AM
  • The subject of this thread includes "Error 1026" but I see no mention of that in the question. What I do see says "unhandled exception"; in other words, there was no try/catch to handle it.

    I am very confused. I can't help.



    Sam Hobbs
    SimpleSamples.Info

    Monday, October 9, 2017 6:07 PM
  • The subject of this thread includes "Error 1026" but I see no mention of that in the question. What I do see says "unhandled exception"; in other words, there was no try/catch to handle it.

    I am very confused. I can't help.



    Sam Hobbs
    SimpleSamples.Info

    Sam, see this thread for full details

    thread

    Tuesday, October 10, 2017 10:17 AM
  • Hi PepinPadin,

    Where you wan to access to do the I/O operation? Have you set the permission of the place you want to access?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, October 12, 2017 11:15 PM
  • Hi PepinPadin,

    Where you wan to access to do the I/O operation? Have you set the permission of the place you want to access?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Please Wendy, read the full thread before posting something like this.
    Friday, October 13, 2017 4:00 PM
  • I´ve tried to set logging through this two registry values

    https://www.opcsupport.com/link/portal/4164/4590/Article/763/How-can-I-enable-DCOM-logging-in-Event-Viewer

    but, no event was generated at System and Application Log.

    Monday, October 16, 2017 7:03 PM
  • Hello,

    Generally, to solve these kind of issues someone needs to be familiar with the library you're using so the best advice I can give you here is to contact the vendor and see whether they provide any kind of support to handle the issue you're having, alternatively, try to check whether they release the source or decompile it and then you can and see exactly at what point the exception is thrown using the debugger.

    You are free to contact me through msdn at solnik net for anything related to the C# forum. Cheers, Eyal Solnik

    Wednesday, January 3, 2018 12:37 PM
  • Hello,

    Generally, to solve these kind of issues someone needs to be familiar with the library you're using so the best advice I can give you here is to contact the vendor and see whether they provide any kind of support to handle the issue you're having, alternatively, try to check whether they release the source or decompile it and then you can and see exactly at what point the exception is thrown using the debugger.

    You are free to contact me through msdn at solnik net for anything related to the C# forum. Cheers, Eyal Solnik


    Sorry Eyal, but your post is not helpfull at all. MBNApi is offered directly by Microsoft and I have no access to the source code
    Wednesday, January 3, 2018 12:48 PM
  • Sorry for trying.

    You are free to contact me through msdn at solnik net for anything related to the C# forum. Cheers, Eyal Solnik


    • Edited by Eyal Solnik Saturday, January 6, 2018 8:11 AM
    Friday, January 5, 2018 8:09 PM