I have a legacy VB6 Program that occasionally needs UAC elevation to do some things (mostly copying OCX's and DLL's to system folders). However, this is only 5% of its function, the rest does not require UAC. Is it possible to code it to request UAC elevation only when needed, thus not needlessly prompting the user for UAC each time the program is run?
I did find on the internet, some people wrote an elevation command, the problem with this is that it causes each OCX and DLL to require a UAC prompt (about 30 of them each time) so this is no good.
I'd also rather not recursively run the program, the program shelling to itself but with elevation, that could get nasty.
Anyone got any ideas?
This conversation is currently closed to new comments.
The first one I already knew about, but that only works if you want UAC every time, I only want certain sub procedures to need UAC elevation (The file copying).
Ahh I see, this one may be beyond me, i play with VBscripting,, I did ask a developer here regarding uac issues and our software, they are using some "manifest" technique. Im not that familiar with that but maybe if you look into that it mgith lead you somewhere?
best bet is another executable, runs up if authorised does it's stuff. You can elevate an app easy enough, but you can't 'erm "unelevate", that can get very messy, particularly with things like user profiles, end up adding stuff to the user you elevated to instead of from. Very messy.
Once elevated, it shouldn't cause any additional problems. It should only need to run this code once every few months, but the EXE it self runs at least 10 times a day, so a UAC prompt each time would be aggravating.
An additional EXE is a possibility, and its probably the way I am going to have to do this.
It's by far the easiest. When we did something similar, there was brave attaempt by management to "keep it simple", and not have another process. Turned out to be not simple, not even a littel bit...
Do you think the company will still be using VB6 code in ten years? Inertia can be an amazing thing, but I can't feature VB6 having the same staying power as, say, COBOL.
Another 5 years at least. It handles our installations and dependencies. VB6 has the advantage of being fully supported in Windows XP and up from fresh install. One of the things it installs is .net 1 through 3
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Request UAC elevation at runtime?
However, this is only 5% of its function, the rest does not require UAC.
Is it possible to code it to request UAC elevation only when needed, thus not needlessly prompting the user for UAC each time the program is run?
I did find on the internet, some people wrote an elevation command, the problem with this is that it causes each OCX and DLL to require a UAC prompt (about 30 of them each time) so this is no good.
I'd also rather not recursively run the program, the program shelling to itself but with elevation, that could get nasty.
Anyone got any ideas?