UAC - Required Elevation and Privileges

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

UAC - Required Elevation and Privileges

Post by Pablo César »

Some procedures require administrator rights and so that it does not go down because of the Windows security system (Windows Vista or later), we use need to elevate privilages even been the user logged as admin.

I've got three examples which can attend these proposes or even serve as examples.
 
UAC.rar
Source files
(5.93 KiB) Downloaded 244 times
 
Screen50.png
Screen50.png (12.16 KiB) Viewed 4867 times
Please note which is in Demo2.rc file contains. ;)
 
UAC (Exe).rar
Executable files
(3.72 MiB) Downloaded 213 times
 
I hope you enjoy it and all your contributions are welcome. :P
 
However, with respect to ShellExecuteEx, I would like to replace the file execution in the same way by a process which would it prevent the recursive method... :oops:

I used the recursive method to avoid creating another executable. So I use the same parameter to differentiate its execution from within the same application.
 
Has anyone done anything similar with processes without having to create an executable ?
 
Would it work with __pp_Process (ShellExecuteEx run with Harbour's PreProcesor) ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: UAC - Required Elevation and Privileges

Post by srvet_claudio »

Pablo César wrote: Sun Jan 15, 2017 6:12 pm
However, with respect to ShellExecuteEx, I would like to replace the file execution in the same way by a process which would it prevent the recursive method... :oops:

I used the recursive method to avoid creating another executable. So I use the same parameter to differentiate its execution from within the same application.
 
Has anyone done anything similar with processes without having to create an executable ?
 
Would it work with __pp_Process (ShellExecuteEx run with Harbour's PreProcesor) ?
I'm sorry but I don't understand what you say.
You need work with Threads?
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

UAC - Required Elevation and Privileges

Post by Pablo César »

Claudio wrote:You need work with Threads?
Yes Claudio. Do you think real possible threads can be run with the ShellExecuteEx that I made available in Demo3.prg. Is this possible ?
Please note that ShellExecuteEx works with "runas" to request UAC execution permission as administrator. Is it possible to run thread instead an executable file ?

Thank you Claudio for your idea and your attention for responding.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: UAC - Required Elevation and Privileges

Post by srvet_claudio »

Now I understand, what you need is to create a process as an administrator, see for example:

http://stackoverflow.com/questions/1158 ... nt-have-th

https://www.codeproject.com/kb/vista-se ... vator.aspx
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: UAC - Required Elevation and Privileges

Post by srvet_claudio »

Thread is a separate subprocess (routine) inside your exe file. Process is a separate program that run out of your exe file.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

UAC - Required Elevation and Privileges

Post by Pablo César »

Gracias Claudio por tus indicaciones. La mayoria creo haberlo leído, tal es asi que el código de Demo3.prg que disponibilicé en mi primer mensaje ya posue el ShellExecuteEx con "run as". Aprovechando la ocasion: podrias decirme si ese código está correcto? Me refiero más a sobre eliminar el proceso al final. O seria mejor si tuviera el retorno de si ejecutó o no, pues el usuário puede negarse al responder el mensaje UAC.
Pero lo que preciso saber es si el ShellExecuteEx aceptaria una funcion (por ejemplo) en lugar de un arquivo externo. Quiero escapar de tener que hacer otro archivo ejecutable. Aunque por lo que todo indica: no tengo otra salida. Todavia no he visto ningun ejemplo de Thread que manipule el REGISTRY como quiero en este ejemplo.
Pioenso que puedo hacer un archivo .REG obedeciendo los comandos del própio REGISTRY. O entonces hacer lo equivalente en .VBS.

Y aí si ejecutarlos atravez del ShellExecuteEx.
 
Googled
 
Thank you Claudio for your suggestions. Most I think I've read it, so the Demo3.prg code that I provided in my first message already has ShellExecuteEx with "run as". By the way: could you tell me if that code is correct? I mean more about removing the process at the end. Or it would be better if it had the return of whether it executed or not, as the user can refuse to respond to the UAC message.
But what I need to know is whether ShellExecuteEx would accept a function (for example) instead of an external file. I want to escape having to make another executable file. Although by all indications: I have no other way out. I have not yet seen any example of Thread handling the REGISTRY as I want in this example.
I think I can make a .REG file obeying the commands of the REGISTRY itself. Or do the equivalent in .VBS.

And then if you run them through ShellExecuteEx.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

UAC - Required Elevation and Privileges

Post by Pablo César »

I was able to do it via VBS + ShellExecuteEx file
 
UAC.rar
Source files
(2.28 KiB) Downloaded 215 times
UAC (Exe).rar
Executable file
(1.24 MiB) Downloaded 213 times
 
It is missing if the ShellExecuteEx function I did would be better with return or with process deletion.
 
Please Claudio, could you give me a light ? And how to do it in C language in case ?
 
Note: I did not do it through .REG files because this would have to be in the binary hive format (too complicated). Even more taking into account the version of Windows should be in UNICODE or ANSI
Last edited by Pablo César on Mon Jan 16, 2017 3:55 pm, edited 2 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: UAC - Required Elevation and Privileges

Post by serge_girard »

Thanks Pablo,

What exactly can we do with it? Or how to use it, in which cases can it be useful?

Serge
There's nothing you can do that can't be done...
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

UAC - Required Elevation and Privileges

Post by Pablo César »

Hi Serge, thanks for your interest.

Please read this and see if answer your questions.
Pablo César wrote: Sun Jan 15, 2017 6:12 pm Some procedures require administrator rights and so that it does not go down because of the Windows security system (Windows Vista or later), we use need to elevate privilages even been the user logged as admin.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: UAC - Required Elevation and Privileges

Post by serge_girard »

OK Pablo, this is a bit clearer!

Serge
There's nothing you can do that can't be done...
Post Reply