none
[C#]How to run program(exe or batch file) as currently logged in user account from windows service? RRS feed

  • Question

  • I created Windows service program using C#.

    Account of Windows service is SYSTEM.

    I want to remove credentials under current user account.

    However, it seems that Windows service can only access credentials of SYSTEM account.

    So I want to remove credentials by running exe or batch file with currently user account from windows service.

    I found to change session but user name is not changed.

    How can I do?

    Sunday, April 5, 2020 8:50 AM

Answers

  • Hello,

    Running anything from a Windows Service uses the same credentials that "system" has which are as you learned limited so you can't remove credentials from a user account.  Whatever the reason for doing this you need to consider a different path. Usually in a company environment permissions are controlled through a support team in tangent with Active Directory. On a personal computer the user is in control assuming they have admin permissions or run as admin.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by 라바 Monday, April 6, 2020 4:29 AM
    Sunday, April 5, 2020 9:21 AM
    Moderator