Run as Administrator

Started by ceciltss, June 28, 2013, 02:23:26 PM

Previous topic - Next topic

ceciltss

Hi there,

I have been out of this for a while, so this may seem a trivial question.  Unfortunately, I could not find an answer either in tech support or the existing forum.  So here goes.

I have a program which sometimes needs to be Run As Administrator.  In theory, I convey the difference using a menu call or I could theoretically detect the privilege state and error out if insufficient for the purpose.  To do the first, I need Run*(), ShellExecute(), or something similar which has a "Run As Administrator" parameter.  Unfortunately, I have not found such a thing.  To do the second, I need a way to determine using code if Administrative Privilege is in force.  Again, I have not found such a function.

I really don't want to use the "Request Admin Priv" option on the compiler since most of the time this program will not need it and it could make normal usage significantly inconvenient.

Well, thanks in advance for your attention and for any advice you can give me.  I look forward to hearing from you.


Deana

Not as trivial as would first appear...These types of operations have changed a lot with the introduction of UAC. Can you provide more information about which windows platforms you intend to run on?

Also will this script be run from Administrative accounts? Or will it be run from Standard user accounts as well?

On a system with UAC (Vista or newer): One possibility is to have two separate scripts one that runs as a standard user with AsInvoker manifest settings, then another compiled using the RequireAdministrator manifest setting. You could then launch the RequireAdministrator using the ShellExecute function, the user will then be prompted for Administrator password.

For more about UAC see the Windows Interface Language help file.

Deana F.
Technical Support
Wilson WindowWare Inc.

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

ceciltss

Thanks for your replies.  They were helpful.

I looked at my app and fortunately it breaks easily into two functions.  One specific function needs admin privilege and can be split off and compiled for admin use and the rest of the functions can stay in a common use file.

Btw, did I say "I hate security, it only gets in my way."?