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

  • SEARCH
  • Home
  • 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 7445775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:06:51+00:00 2026-05-29T12:06:51+00:00

I’m confused. I have program which I run as a non-administrator user. This program

  • 0

I’m confused. I have program which I run as a non-administrator user. This program can write files in my C:\Program Files\ folder.

However, if I launch a second program using CreateProcess from within the first program, the second program cannot write to the C:\Program Files\ folder.

What are the correct parameters to pass into CreateProcess() to use the same access privileges as the first launching program? I’ve tried setting the 3rd and 4th parameters as NULL but that didn’t seem to work.

BOOL RunCmd( char  *pCmd, 
             char  *pParams, 
             char  *pWorkingDir, 
             int    nWaitSecs, 
             BOOL   fQuietMode, 
             DWORD *pdwExitCode )
{
  BOOL                fSuccess = TRUE;
  STARTUPINFO         si;
  PROCESS_INFORMATION pi;

  ZeroMemory( &si, sizeof(si) );
  ZeroMemory( &pi, sizeof(pi) );

  si.cb          = sizeof( si );
  si.dwFlags     = STARTF_USESHOWWINDOW;
  si.wShowWindow = ( fQuietMode ) ? SW_HIDE : SW_SHOW;

  // PDS: This is the important stuff - file handle needs to be inheritable..
  SECURITY_ATTRIBUTES sFileSecurity;
  ZeroMemory( &sFileSecurity, sizeof( sFileSecurity ) );
  sFileSecurity.nLength        = sizeof( sFileSecurity );
  sFileSecurity.bInheritHandle = TRUE;

  char txCmdLine[ MAX_PATH * 2 ];

  strcpy( txCmdLine, "\"" );
  strcat( txCmdLine, pCmd );
  strcat( txCmdLine, "\"" );

  if( pParams )
  {
    // PDS: Add any parameters if we have them..
    strcat( txCmdLine, " " );
    strcat( txCmdLine, pParams );
  }

  int rc;

  // Start the child process. 

      rc = CreateProcess( NULL, // No module name (use command line). 
                          txCmdLine, // Command line. 
                          &sFileSecurity,             // Process handle not inheritable. 
                          &sFileSecurity,             // Thread handle not inheritable. 

                          FALSE,

                          // PDS: Don't pop up window for application.. quiet mode!
                          CREATE_NO_WINDOW,
                          NULL,             // Use parent's environment block. 
                          pWorkingDir,      // Working folder
                          &si,              // Pointer to STARTUPINFO structure.
                          &pi );            // Pointer to PROCESS_INFORMATION structure.
  • 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-05-29T12:06:52+00:00Added an answer on May 29, 2026 at 12:06 pm

    Apologies – the primary program couldn’t create the file either. The issue was confused by the fact that the primary program was being launched from an installation program that was run as an administrator. The system then rebooted and the primary program was auto-started with the current user’s access privilege.. who didn’t have access to the folder.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6

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.