Create .exe in Qt with admin privilege - c++

I've coded a programm that require to be run as an admin privileges. I'm aware that I can do that through going to property/Compatibility/Run as adminstrator in Windows but how can I do that if possible to make it programmatically, so that when launched programm automatically gained Adminstrator privilege level?

Yes, with an application manifest that requests admin privileges.
http://msdn.microsoft.com/en-us/library/bb756929.aspx
(This will still ask the user whether he wants that, of course. And if your account cannot have admin privileges, the user will also have to use Run As to choose a different account.)

Related

Is it possible in Intune to set up this policy that every time a user wants to download,copy & delete something,the admin has to get the notification

Is it possible in Microsoft Intune to set up this policy that every time a user wants to download, copy, or delete something, the admin has to get the notification?
Is it possible to prevent the user from installing any app or software unless the admin grants permission? If the user wants to install something, the admin must grant permission.
If anyone has knowledge on these two types of policies, please send the required settings. It will be so helpful for me.
I tried using the AppLocker but it is blocking ever app installation so I need customized restriction
Is it possible in Microsoft Intune to set up this policy that every time a user wants to download, copy, or delete something, the admin has to get the notification?
On mobile devices, you can block downloads or copies by application protection policy (same for W10). Or if you have a license for DLP, you can use the technology to audit events. Don't forget the cloud apps.
Is it possible to prevent the user from installing any app or software unless the admin grants permission? If the user wants to install something, the admin must grant permission.
We don't use this option but in device configuration, there is some restriction option that can block these features

Gsuite Windows Admin and Non-Admin Users

I see that you have the option of setting the default account in windows in Google-Workspace Admin as a standard user or a Administrator. I wanted to ask is it possible that if a particular user signs in he gets a local account while another user when he signs in ..signs in as Windows Administrator?
I want to have two Workspace accounts on the windows. One with no admin privileges and other with admin privileges and no local Admin accounts. Only Workspace accounts should be on the system. However, in Google Admin, if I choose standard then ALL the users become standard. That is not what I want. I want to be able to choose. Is this possible?

Prompt to restart a process for administrative privilege

I am the only user and admin of my computer. My account doesn't have password because the computer is located in a secret room. I want to restart a process as administrator.
I don't want to change manifest because it makes the process to run always on administrative privilege.
I want administrative privilege only when I need it.
Using functions CreateProcessWithLogon, LogonUser and command tool runas.exe is not appropriate for me because I have no password.
What can I do? Moreover when I run an application as administrator, it prompts but it doesn't ask for password. Is there any way to make such a prompt?
Moreover when I run an application as administrator,it prompts but it doesn't ask for password.Is there any way to make such a prompt?
It would ask you for the password if you attempted to run the application as administrator from user account with limited user rights (non-admin).
If you wish to run under admin rights only when you really need them, you should split your application to two parts: one part would run under limited rights, the other, only capable to do the administrative actions and nothing more, would be run only at need (so it should not "run away").

QDesktopServices::storageLocation returns admin folder after elevating program

parts of my application suite (client + updater) needs administrator rights for correct behaviour. My client application uses QDesktopServices::storageLocation() in various places to get the correct user profile path for saving user specific data. But as soon as im using QDesktopService::storageLocation() in an elevated application the path changes to the admin user, which makes it difficult to control.
Like from "C:\Users\basic_user\AppData\Local" to "C:\Users\admin\AppData\Local".
Is there a way to deal with this with qt or is my only possibility to use the WinApi?
What is the "right way" when facing the scenario of having an elevated app but one still needs to operate in the user space.
regards,
adrian

Creating Firewall rule for a process running in a Non-admin user account

I have a basic requirement - to run my application smoothly on Windows by creating firewall rules when prompted, that has windows firewall turned-ON.
When I log in to my system as an user with Admin privileges when I run my application the first time, the firewall comes up with a prompt, I inform it to allow my app and create a rule, nice.
However when I turn-on my PC, log in as a non-Admin user, and I run my application, the firewall shows up with a prompt as expected; however when I click on the same options as I did from the Admin user, the firewall prompt keeps popping up continuously even though I clicked on Allow /ok every time the prompt appears. The prompt only goes away when I click on "Cancel / Block" the application from running, which is obviously not what I want to do.
So here comes the million $ question, What and How should I change my application code to run smoothly by creating the firewall rule successfully the first time I click on the firewall prompt to allow my application; exactly the same way it is working when I run my application as an user with Admin privileges.
I have done my bit of searching online and have come to understand that Non-admin users cannot modify firewall rules (cannot even create them???). BTW I have tested this scenario on Windows XP, Vista 7 both x86 and x64 with same results.
If someone has encountered and / or solved similar issues please share your knowledge. If I am missing something, please make me understand what I am missing.
Thanks
I don't think what you are trying is possible in a non-admin account. What you may try is to gain admin privilege by using the windows runas feature by creating a new process, so that the user is prompted for the username and password of the Admin Account, which would give your program the required access to create firewall rules for your program.
You may also take a look into CreateProcessAsUser or LogOnUSer . Basically in order to succeed in what you are trying to do, you need a token that represents the Administrator account or an account which has admin privileges.