How to start a Process as administrator mode

M

MA

Hi all,

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

"C:\ProgramData\CompanyName\SomeFolder\somefile.dll"

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

takeown /f "C:\ProgramData\CompanyName\SomeFolder\somefile.dll"
icacls "C:\ProgramData\CompanyName\SomeFolder\somefile.dll" /grant
BUILTIN\Users:RWM

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.StartInfo.FileName = @"C:\Windows\System32\takeown.exe"
process.StartInfo.Arguments
=@"C:\ProgramData\CompanyName\SomeFolder\somefile.dll /grant
BUILTIN\Users:RWM";
process.Start();
process.WaitForExit();
-----------------------------------------------------------------

Thanks in advance for your suggestions.

Kind regards,
MA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top