Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Windows-10 app elevated but without UAC prompt

Status
Not open for further replies.

bonifale

Programmer
Sep 4, 2003
74
0
0
GB
Hi all
This is driving me mad...
I need to send an update package (C#) to run on a Win-10 Pro machine in another country.

This package, among other locations, needs to copy files to 'C:\Program Files\' and therefore needs to run elevated.
The package works okay as I normally run it as Administrator; but cannot give the admin password to the users in the other country. Naturally UAC prevents it running and prompts for a password.

I know the Admin password so I thought I could create an app that auto elevates and then calls the update package and found what seems to be a good method at;
I produced the code below that simple doesn't work; still get the UAC prompt.

Any help would be most appreciated and save me shipping the equipment back from India to the UK.

--

using System.Diagnostics;
using System.Security;

namespace PackageUpdate
{
class Program
{
static void Main(string[] args)
{
var pass = new SecureString();
pass.AppendChar('s');
pass.AppendChar('e');
pass.AppendChar('c');
pass.AppendChar('r');
pass.AppendChar('e');
pass.AppendChar('t');

Process.Start(@"AccessTest.exe", "administrator", pass, "");
}
}
}
 
Instead of installing in Program Files, why not install in ProgramData. You don't need to be admin to install anything in ProgramData and it is globally visible to all users. I know that is not what ProgramData is meant for but it solves the admin privilege problem.
 
Hi xwb

thank you for the speedy response; good idea but the problem is that the machine is already in India (i'm in the UK).
We need to update existing software that is already installed in program files and cannot give them the password.

Anyway I was mistaken; the code I posted does work and I had made another error; so all is well now.

Hope this thread is of help to others though.

Thanks
Les....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top