4

So here is my issue:

I have start a .bin file, which is just a .exe, renamed to .bin, with administrator privileges.

Here is what I have:

PSI.FileName = "Client.bin";
PSI.WorkingDirectory = Directory.GetCurrentDirectory();
PSI.UseShellExecute = false;
PSI.Verb = "runas";
Process.Start(PSI);

I also have the requireAdministrator set in the manifest.

I have to set UseShellExecute to false, seeing is that is the only way I can find that starts the .bin as a .exe. However, according Here, runas, and the manifest only are used when UseShellExecute is set to true.

Question: How to start a non .exe process, with elevated privileges?

Aqua256
  • 63
  • 1
  • 6
  • 1
    So, why can't you use ShellExecute? If the file is a valid PE executable, it doesn't matter what the file extension is. – Cody Gray - on strike Aug 14 '14 at 12:04
  • Why not rename the file? – ZippyV Aug 14 '14 at 12:05
  • Check out the app manifest file, you can specify that your app requires elevated permissions. As a result, any process that you start from within your application should then run with elevated permissions, if I remember correctly. – jay_t55 Aug 14 '14 at 12:21
  • If you set UseShellExecute, it tries to just start the file, as if you were double clicking it. So, because no file association exists for .bin file, there is an exception. @Jason, that only is taken into account when ShellExecute is true. Also, can't rename the file, it's for a client, and it "isn't possible" – Aqua256 Aug 14 '14 at 12:48

2 Answers2

0

Have a parent process which is a executable with administrative privilege & then launch the ".bin" file from it.

dvasanth
  • 1,337
  • 1
  • 9
  • 10
0

According to this answer this is not possible to run .bin file with elevation directly.

At least you can run your own .exe with runas (and ShellExecute = true) and order it with commandline to run .tmp (without ShellExecute, but the process is already elevated) and die. But this is the "last chance" solution.

rattler
  • 379
  • 2
  • 5
  • 15