问题
Is there a way to, via programmatically, auto-fill in the UAC login name and password in Visa?
For instance, the UAC prompt comes up. Your program auto-fills that information for you.
E.g., a program that would auto-fill that information with an administrator username and password in the UAC prompt.
SendKeys does not work to send input keys to the UAC dialog box
回答1:
There are several levels of UAC. I believe what you want is not possible if you use the UAC with the "greyed" screen. This mode is there to specifically not allow other programs access to the UAC-Window.
回答2:
If yu're logged into the machine as an administrator, you don't need to provide an ID and password, just click Consent. If you have the good habit of not signing on as an administrator, you can relax that habit now because UAC prevents your admin powers being used without your knowledge.
回答3:
Why are you looking to do this?
Do you wish to have a program you're creating bypass UAC? If so, you should rewrite your program to require less elevated privileges.
If you're looking to do this so that you're not bothered with UAC, you can turn it off in the control panel. Search "UAC".
Finally, if you want UAC but you want to be able to quickly enter your credentials I would suggest AutoHotkey. That program has a record function which you could use to create a macro that would fill in your credentials in the UAC window every time you press the designated hotkey.
来源:https://stackoverflow.com/questions/4378135/programmatically-auto-fill-uac-details