How to run code as "administrator" user with UAC enabled.

We have a terminal server running Windows 2013 R2. We need to run an application that we wrote to periodically register a .dll file as the domain administrator. The code works on a computer without UAC enabled.

Once UAC is enabled the code will no longer work. Please see the function attached.   code.gif
PROACTIVETGAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JohnBusiness Consultant (Owner)Commented:
A person needs admin authority to register a DLL. That is normal and UAC should not be disabled (because of other security concerns).

How often to you need to register this DLL?  Register it once and then done?
0
PROACTIVETGAuthor Commented:
In the code we have the credentials of the administrator (encrypted).

We need to register the .dll files only after software upgrades of a specific accounting application. Seems the application upgrade works but misses the last part of the upgrade (registering the .dlls). Since there are so many upgrades we want users to upgrade the application but they do not have rights to register .dlls.
0
JohnBusiness Consultant (Owner)Commented:
What we do for our QuickBooks clients is schedule the upgrades so we can go to all the machines in one client and upgrade QB. We do that as administrator. This works fine.

I am not sure what to suggest short of reducing the number of upgrades or scheduling them so they can be managed.

Turning off UAC is indeed dangerous.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

PROACTIVETGAuthor Commented:
Understood. What we are really looking for is someone to help us run the C# code. See attached script.
0
PROACTIVETGAuthor Commented:
No one have an answer?
0
JohnBusiness Consultant (Owner)Commented:
Any code that registers DLL's or does like work, needs to run as Administrator and have UAC authorized at the time of the install. I have not seen installs as you wish run as an ordinary user.

So I think you have to run scheduled maintenance at the computers to do what you want.
0
PROACTIVETGAuthor Commented:
So what I'm asking is not possible?
0
JohnBusiness Consultant (Owner)Commented:
Yes. What you want by code is not possible in the same way that standard users cannot run things requiring admin credentials.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.