Page 1 of 2

UAC - Required Elevation and Privileges

Posted: Sun Jan 15, 2017 6:12 pm
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 264 times
 
Screen50.png
Screen50.png (12.16 KiB) Viewed 5235 times
Please note which is in Demo2.rc file contains. ;)
 
UAC (Exe).rar
Executable files
(3.72 MiB) Downloaded 236 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) ?

Re: UAC - Required Elevation and Privileges

Posted: Sun Jan 15, 2017 10:52 pm
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?

UAC - Required Elevation and Privileges

Posted: Sun Jan 15, 2017 11:41 pm
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.

Re: UAC - Required Elevation and Privileges

Posted: Mon Jan 16, 2017 1:26 am
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

Re: UAC - Required Elevation and Privileges

Posted: Mon Jan 16, 2017 1:33 am
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.

UAC - Required Elevation and Privileges

Posted: Mon Jan 16, 2017 11:36 am
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.

UAC - Required Elevation and Privileges

Posted: Mon Jan 16, 2017 3:43 pm
by Pablo César
I was able to do it via VBS + ShellExecuteEx file
 
UAC.rar
Source files
(2.28 KiB) Downloaded 240 times
UAC (Exe).rar
Executable file
(1.24 MiB) Downloaded 236 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

Re: UAC - Required Elevation and Privileges

Posted: Mon Jan 16, 2017 3:52 pm
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

UAC - Required Elevation and Privileges

Posted: Mon Jan 16, 2017 3:58 pm
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.

Re: UAC - Required Elevation and Privileges

Posted: Mon Jan 16, 2017 4:00 pm
by serge_girard
OK Pablo, this is a bit clearer!

Serge