This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Vista UAC, Access Elevation and .Net
I have a special feature in my AP, this feature need to get administrator right in Vista. Is there any MS API to pop up the UAC dialog when I click the button? Because I don’t want the end-user to see UAC dialog during startup, the feature is really special, not every user will do that. Thanks in advance.
Nope, MS has spent lots of time to make programmatic access to that button impossible! If you could do such a thing, UAC would be absolutely useless. You might encapsulate the functionality as a something (e.g. a Windows service) running with admin privileges. on which you'll call a method from the non-elevated process.
Related
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 23 days ago.
Improve this question
On my Windows 11 computer I'd like adjust a few settings programtically (hidden). Basically it should be performed without elevated rights, so standard users can use it too. By the way, it's my own idea, no office work.
Currently I try to turn off the standard startup sound in mmsys.cpl -> Sounds. Though its a global settings for all users, from within the GUI its easy to do (simply unchecking the box) and doesn't need elevated rights. Strange, but seems like intended by Microsoft.
But I have to do it without any GUI. There are several posts online how to change it in registry (under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation "DisableStartupSound") but all of them require administrator rights.
Assuming unchecking in GUI pass a specific command that triggers the registry key to be changed, I would like to know that command. Workarounds are welcome - as long they doesn't need admin rights or cause a GUI to get open. Scripts like batch, vbs or powershell are as good as an executable.
Does anyone have an idea?
Writing to HKLM does require elevated rights for most keys.
The Settings app is either using UAC auto elevation (only for Microsoft apps) or asking a service to change the registry on its behalf. Process Monitor should be able to tell you which process is writing...
On my Windows 10 system the registry permissions for the BootAnimation key are set so that all authenticated users can set the value. Reg.exe does not seem to work because it asks for too many permissions but WSH works:
CreateObject("WScript.Shell").RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation\DisableStartupSound",1,"REG_DWORD"
..and save as a .vbs
Where I may get whitelist uac binaries (default) for windows 7. I am try looked in msdn, google, but nothing found. I know about this lists 1 and 2, but how he build them...
I whant build same list for my system.
[Note: A moderator deleted my previous reply, which was marked with three upvotes, so I am posting it again. It does provide an answer to the question by getting to the question behind the question.]
We would need to know the reason why you want a whilelist. If UAC is enabled, you cannot bypass the UAC prompt, and this is by design. See FAQ: Why can’t I bypass the UAC prompt? for more information. Excerpt:
If it were possible to mark an application to run with silently-elevated privileges,
what would become of all those apps out there with LUA bugs? Answer: they'd all be marked
to silently elevate. How would future software for Windows be written? Answer: To
silently elevate. Nobody would actually fix their apps, and end-user applications will
continue to require and run with full administrative permissions unnecessarily.
I'm marking this as a community wiki because I'm not really looking for one complete answer. So if you feel like posting one or two things that will activate the UAC prompt instead of a comprehensive list then go ahead.
What actions in Windows will activate UAC? I'd like to avoid it as much as possible because my application doesn't need admin privileges. And I'm sure many other people want to avoid it.
Specifically, I would like to know if reading from the registry would activate it. Or writing to it?
You don't need to address the above question, just anything that will activate it is fair game.
It's really hard to Google anything about UAC because you get bombarded with articles about how to disable it. And I'd rather not have my application make the assumption UAC is disabled.
Nothing "activates" UAC.
If your application would fail to run as a standard user under Windows XP it will fail to run under Windows Vista or Windows 7 as a standard user.
What you are really asking is: what actions can a standard user not perform under Windows?
The things a standard user cannot do are pretty well known (they've been the same since Windows 2000). The main ones are:
modify anything in HKEY_LOCAL_MACHINE
modify anything in the Windows directory
modify anything in the Program Files folder
If you try to do any of those they will fail on:
Windows 2000
Windows XP
Windows Vista
Windows 7
Nobody should have been running as an administrator for day-to-day computer use. If your application did any of those bad things in Windows XP it would fail. The user would have to:
logon (or fast user switch) to an administrator
perform the administrative task
switch back to their real account
UAC is a convience mechanism, allowing you to easily temporarily switch to an administrator. Nothing you do will "trigger" it; you have to make it happen.
If you know your code needs to modify a file in C:\Program Files\My App\Data, then you should add a button on your form that will trigger the elevation.
You then need to launch an (elevated) copy of your program, do the thing, and close.
I created a launch4j installer (an exe-wrapper for java programs) and named it "MyApp.exe". It doesn't need any admin authentication. It just runs fine without any UAC prompt.
BUT: If I rename this installer to "install.exe" or "setup.exe", the UAC icon appears and I get a UAC promp when starting the installer.
Seems as if there are some "reserved words" in filenames that cause windows to start a program with elevated rights (UAC).
I made an updater which silently runs in XP and works just fine. But when it comes to Vista, the idea of silent installation gets ruined when UAC prompts the user to cancel or allow the user from running the program.
Is there anything at all we can do about this?
Thanks...
I know this post is old... 4 months to be exact. But Actually, yes it is VERY VERY possible. I wish to correct the people above.
Just add this line to your NSIS script.
RequestExecutionLevel user
This line tells Windows Vista and Windows 7 that this program does not require administrative access, which Vista/7 thinks.
Unfortunately there's no way around this. UAC is actually intended specifically to prevent this type of thing where programs install software or make changes to the machine without the user's awarness.
This is effectively a side effect of UAC and user permissions. From a security perspective, it does make sense.
If this is something you need to do, you should look to implement a system that is designed to run patching and deployments with elevated permissions. Microsoft's own Systems Management Server would do the trick, but is obviously quite a large scale solution!
You can read about it here.
UAC for non-MSI installs is a bit of a grey area, with signed MSI packages things get much easier and less confusing for the user.
You might want to take a look at Clickonce Deployment which may solve some of your problems.
Actually, it is possible, under very preconceived circumstances. Specifically, "service" can launch an installer, in a user session, with full privileges and bypass UAC prompting (already has it).
Of course this requires your user to have already installed your service, which DOES require Admin approval.
Question says it all really...
I have tried changing the "Allow non-admin users to run this program" setting on the property pages, and have also given the non-admin user in question what looks like the correct privileges in Component Services -> DCOM Config.
Is there anything else I can do ?
This is on Server2003 BTW.
Thanks
Matt
http://support.microsoft.com/kb/183607
I saw your question a few days ago, but didn't answer because all I have is something for you to try. I expected someone else with knowledgeable answer to respond, but since you still have no answers I'll tell you the little bit I know. When our tech support department installs our app onto a computer running XP or Vista they log in with an administrator account the first time they run the app. Apparently that allows what ever needs to happen with the ActiveX DLLs to work. After that the users can log in with their regular account and the app is still happy.