1

I need to start an application from another application. It looks like I have to use the shell to do it (since I need to be able to close the launcher), but I also would like to downgrade the rights given to the launching application.

Is this possible? The launcher must run as administrator, but I'd like to have the launching application run as user.

this is how I currently run the process:

Process process = new Process();
process.StartInfo = new ProcessStartInfo();
process.StartInfo.FileName = name;

process.Start();

Forgive me I forgot to add a couple of details:

  • I need to run it in .net 3.5 on mono
  • I'd prefer to not use native code
  • I need to run the launcher application in admin mode
John Saunders
  • 160,644
  • 26
  • 247
  • 397
sebas
  • 1,045
  • 12
  • 27
  • I'd look into the "runas" verb ... to run as admin I believe you use runas with no param. I think you may be able to do the opposite – Alan Jul 01 '13 at 18:54
  • please check this link http://stackoverflow.com/questions/6413900/launch-a-process-under-another-users-credentials – srsyogesh Jul 01 '13 at 18:56
  • 1
    See this answer. It recommends not starting as admin in the first place http://stackoverflow.com/a/7880040/187697 – keyboardP Jul 01 '13 at 18:58
  • 1
    I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Jul 01 '13 at 19:27
  • I am now testing the "starting not as admin" solution, question is how can I start the launcher with elevated rights and redirect the output as well? It looks like I cannot! – sebas Jul 03 '13 at 11:34

2 Answers2

1

This seems to be have discussed before, check this out: How do you de-elevate privileges for a child process

Looks like an UAC elevation is strictly one-way, so the solutions are a bit gnarly, i.e. code injection into explorer and stuff like that.

http://www.codeproject.com/Articles/18946/High-elevation-can-be-bad-for-your-application-How

Community
  • 1
  • 1
Chris
  • 5,442
  • 17
  • 30
  • theoretically I could use also the last solution, because I do not need to capture the output – sebas Jul 01 '13 at 19:30
  • rundll32.exe seems to be not reliable, I must discard the codeproject solution unluckily. – sebas Jul 02 '13 at 14:37
  • How about if you make your application in two parts then? Begin with one unprivileged boot strap part. Have that start your privileged part, and then add some mechanism for your priviledged part to communicate back to the first one to have that start the other app. Definitely more complicated though, but at least it should be reliable. – Chris Jul 02 '13 at 14:53
  • I am now testing the "starting not as admin" solution, question is how can I start the launcher with elevated rights and redirect the output as well? It looks like I cannot! – sebas Jul 03 '13 at 11:36
0

Eventually I decided to create a bootstrapper that could run the launcher as administrator, but then the application as normal user. Once the launcher is done it goes back to the bootstrap executable which launches the application.

sebas
  • 1,045
  • 12
  • 27