Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8915817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:04:39+00:00 2026-06-15T05:04:39+00:00

I have a windows service with StartType = stSystem. It executes an application with

  • 0

I have a windows service with StartType = stSystem.

It executes an application with the CreateProcessWithLogonW.

 usr := 'myuser';
 dmn := 'mydomain';
 pwd := 'thepassword';
 cmd := 'c:\myapp.exe -calculate';
 wdir := 'c:\';

 fillchar(si, sizeof(si), 0);
 si.cb := sizeof(si);

 if not CreateProcessWithLogon(
           PWideChar(usr),
           PWideCharOf(dmn),
           PWideChar(pwd),
           LOGON_WITH_PROFILE,
           nil,
           PWideChar(cmd),
           NORMAL_PRIORITY_CLASS or CREATE_NEW_CONSOLE or CREATE_NEW_PROCESS_GROUP,
           nil,
           PWideChar(wdir),
           si,
           pi
         )
        then
          RaiseLastOSError; // raises Code 5: Access Denied

Running this code outside the service, everything goes fine!

Why the CreateProcessWithLogon raises a system error Code 5: Access Denied ?


Can be this the cause?

MSDN article on CreateProcessWithLogonW says:

Windows XP with SP2 and Windows Server 2003: You cannot call CreateProcessWithLogonW from a process that is running under the LocalSystem account, because the function uses the logon SID in the caller token, and the token for the LocalSystem account does not contain this SID. As an alternative, use the CreateProcessAsUser and LogonUser functions.

I’m using Windows 7 PRO x64

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:04:40+00:00Added an answer on June 15, 2026 at 5:04 am

    You are running the service under the LocalSystem account, and as the documentation clearly says:

    You cannot call CreateProcessWithLogonW from a process that is running under the LocalSystem account, because the function uses the logon SID in the caller token, and the token for the LocalSystem account does not contain this SID.

    So either change the user account that the service runs under, or switch to CreateProcessAsUser(), like the documentation says.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows service created with Delphi 7, with StartType = stSystem. Now
I have an windows service application where I have an object that is processed
I have an issue with windows services, my application registering Windows service but when
I have a windows service application developed in C#. The same service needs to
I have a Windows service application. Currently all admin tasks are done through config
I have a Windows Service application which is performing some calls to SQL Server.
I have written an application in C, which runs as a Windows service. Most
I have a Windows Service Application in which i create WCF services in it.
I have windows service application (no winforms). In Main method I started timer. Timer
I have a Windows service that writes messages to the Event Log. I also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.