I am trying to run cmd command with the following code:
ProcessStartInfo cmd = new ProcessStartInfo("cmd.exe"); cmd.RedirectStandardInput = true; cmd.RedirectStandardOutput = true; cmd.RedirectStandardError = true; cmd.UseShellExecute = false; cmd.CreateNoWindow = true; cmd.WindowStyle = ProcessWindowStyle.Hidden; Process exec = Process.Start(cmd); exec.StandardInput.WriteLine("sc create \"BaliService\" binPath= \"{0}\\BaliService.exe\"", Directory.GetCurrentDirectory());
This command requires admin privelages if I run cmd as an administrator and type a command that works fine, but not when I run this application as an administrator. I added
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
to the manifest file that uac requests every time I open exe.
I saw several questions about this, and they all seem to assume that any processes running under the elevated application will have the same rights, but this does not work for me.
I tried cmd.Verb = "runas"; but not a cube.
c # process
Bali C Dec 31 '11 at 21:05 2011-12-31 21:05
source share