vista opening elevated process
I have been struggling to get my app to work the way i want on vista for few days. I have decided to use 2 exe's The start exe contains a manifest to runas invoker. This exe only has a bas module that opens my main app that prompts for Administrator password. This allows my app to run with full rights. The problem is the prompt for administrator is minimized. How can i use shellexecute to not have the prompt minimized ?
Bas module does not have a hwnd so i supplied the desktop
Code:
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Dim hWndDeskTop As Long
hWndDeskTop = GetDesktopWindow()
ShellExecute hWndDeskTop, "runas", "ChildProcess.exe", "", CurDir$(), vbNormalFocus
Re: vista opening elevated process
I'd think just have one EXE and requesting elevation in its manifest would be enough. There must be something going on I don't know about here.
As far as the prompt being minimized goes, setting the owner hWnd to the Desktop (which doesn't have focus in a meaningful sense at this point) is probably the problem.
That looks right: UAC elevation dialog minimized
Re: vista opening elevated process
Quote:
Originally Posted by dilettante
I'd think just have one EXE and requesting elevation in its manifest would be enough. There must be something going on I don't know about here.
As far as the prompt being minimized goes, setting the owner hWnd to the Desktop (which doesn't have focus in a meaningful sense at this point) is probably the problem.
That looks right:
UAC elevation dialog minimized
You are right don't what i was thinking. My plan is to have 2 exe's with the main standard user program prompting for elevation for certain things.eg when they click a button for program updates. Wish i could prompt for elevation to open a form, i would only need 1 exe
Re: vista opening elevated process
Quote:
Originally Posted by isnoend07
... My plan is to have 2 exe's with the main standard user program prompting for elevation for certain things.eg when they click a button for program updates. Wish i could prompt for elevation to open a form, i would only need 1 exe
Well, that's why the UAC Shield decoration for controls exists: it marks a button, menu selection, etc. as a request to perform some elevated function.
You don't actually need two EXEs though. A program can have a startup Sub Main to detect whether it is being run as the main program or in "elevated helper" mode to handle those secondary functions. Then to perform such an action the "main" copy of the EXE starts a second one with runas.
You can pass command line parameters to the second copy of the EXE so that it knows its role as "secondary" and what it should do for the first program.
Alternatively...
There is a way to create an object via the COM Elevation Moniker. You need a separate DLL though. This results in the DLL being loaded in an elevated DLLHost proxy process. You can probably do much the same thing by writing the DLL as an ActiveX EXE though too, bypassing the need for the standard Windows proxy.
It requires proper registration of your component though, not just a run of regsvr32.
The COM Elevation Moniker
If we ever get a forum somewhere specifically for Vista/UAC issues I have the theme song picked out though: Judas Priest - Breaking The Law. :cool:
Re: vista opening elevated process
Quote:
Originally Posted by dilettante
Well, that's why the UAC Shield decoration for controls exists: it marks a button, menu selection, etc. as a request to perform some elevated function.
You don't actually need two EXEs though. A program can have a startup Sub Main to detect whether it is being run as the main program or in "elevated helper" mode to handle those secondary functions. Then to perform such an action the "main" copy of the EXE starts a second one with runas.
You can pass command line parameters to the second copy of the EXE so that it knows its role as "secondary" and what it should do for the first program.
Alternatively...
There is a way to create an object via the COM Elevation Moniker. You need a separate DLL though. This results in the DLL being loaded in an elevated DLLHost proxy process. You can probably do much the same thing by writing the DLL as an ActiveX EXE though too, bypassing the need for the standard Windows proxy.
It requires proper registration of your component though, not just a run of regsvr32.
The COM Elevation Moniker
If we ever get a forum somewhere specifically for Vista/UAC issues I have the theme song picked out though:
Judas Priest - Breaking The Law. :cool:
Thanks for the info. Think i will stick to my 2 exe plan for now. Sounds like their maybe too many complications opening another copy of my exe as the main exe could be full of data that would probably be lost for some things. That com thing is out of my league and i would have to include a seperate dll.