How to start a Process as administrator mode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?TUE=?=

    How to start a Process as administrator mode

    Hi all,

    In Vista, I am triying to assign the following file read-write-modify rights.

    "C:\ProgramData \CompanyName\So meFolder\somefi le.dll"

    I can do that manually by starting the command promt as administrator mode
    then use the following utility.

    takeown /f "C:\ProgramData \CompanyName\So meFolder\somefi le.dll"
    icacls "C:\ProgramData \CompanyName\So meFolder\somefi le.dll" /grant
    BUILTIN\Users:R WM

    I need to automate this process as part of the installer so I created a C#
    wrapper to perform then above tasks but it does not work it it complians that
    I do not have proper rights. I think reason is because the Process I started
    is not admin. My question is how can I start a process as admin and perform
    the task. See the code below:

    -----------------------------------------------------------------
    process.StartIn fo.FileName = @"C:\Windows\Sy stem32\takeown. exe"
    process.StartIn fo.Arguments
    =@"C:\ProgramDa ta\CompanyName\ SomeFolder\some file.dll /grant
    BUILTIN\Users:R WM";
    process.Start() ;
    process.WaitFor Exit();
    -----------------------------------------------------------------

    Thanks in advance for your suggestions.

    Kind regards,
    MA


  • =?Utf-8?B?TUE=?=

    #2
    RE: How to start a Process as administrator mode

    I have solved the issue by providing the manifest file to the project. The
    video below shows how to do it in VS 2008:
    Browse thousands of hours of video content from Microsoft. On-demand video, certification prep, past Microsoft events, and recurring series.


    Thanks,
    MA

    Comment

    Working...