1

I'm running a program coded in C# where it runs some commands using the code below:

Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.FileName = "C:\\Program Files\\Microvirt\\EmuManager.exe";
startInfo.Arguments = "guestproperty enumerate Emu";

process.StartInfo = startInfo;
process.Start();

string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return output;

Since my application is running with Admin Rights, when I run the code above it uses the admin rights on it, but, for some reason, EmuManager.exe does NOT work if running with admin rights.

So I need a way to run that command without admin rights from my C# application that is running with admin rights and get its output.

Imac
  • 379
  • 5
  • 11
  • Are you sure it is having admin privileges that is causing the problem? Have you tried setting the `WorkingDirectory` property of your `startInfo` to "C:\\Program Files\\Microvirt"? – Chris Dunaway Mar 20 '18 at 16:03
  • @ChrisDunaway Yes I'm sure, Micorvirt support sent me an email talking about that, since I was always running the commands with admin rights and getting errors, then they said that without admin rights it was working, so I'm trying to find an workaround. – Imac Mar 20 '18 at 16:07
  • @AleksAndreev The code in the link seems to work, but it's not possible to use arguments in the process and read its output as I could test. – Imac Mar 20 '18 at 16:29

0 Answers0