Anton Shakalo
Anton Shakalo

Reputation: 458

Using reg.exe in code with limited privileges

I need to get installed software list under restricted user.

I use this code:

string fullString = string.Format("EXPORT \"{0}\\{1}\" \"{2}\" /y", hiveString, keyPath, Path.GetTempFileName());
Log(fullString);
var p = Process.Start(new ProcessStartInfo("reg.exe", fullString) {RedirectStandardOutput = true, UseShellExecute = false,WorkingDirectory = Directory.GetCurrentDirectory()});
Log("Output: " + p.StandardOutput.ReadToEnd());
p.WaitForExit();

On my dev machine I see normal output:

operation completed successfully

No matter what account I use - admin or restricted user.

Then I ran this app on Windows XP under restricted user. And see next in log:

"Output: "

Empty line, yes.

When I run similiar query in cmd - it works fine. I can not understand, what I'm doing wrong.

Why doesn't reg.exe write anything?

Upvotes: 1

Views: 596

Answers (1)

Erre Efe
Erre Efe

Reputation: 15557

You can't call reg.exe without admin privileges. At least not unless you are on Windows Millennium (that's why it doesn't even appear on MSFT Web Site). Imagine what one could do if it were possible...

Upvotes: 1

Related Questions