Executes single commands at a Windows command prompt with elevated privileges after a UAC confirmation, without starting the entire command prompt as administrator in advance.
Windows Vista changed the security concept so that even local administrators on a computer don’t have all their privileges all the time. To perform administrative tasks, the process privileges must first be elevated by confirming the well-known User Account Control (UAC) dialog. Users who are no administrator must enter a user name and password.
While this confirmation isn’t too annoying when starting graphical applications, calling console programs or other commands from a command prompt is very cumbersome. The UAC dialog is not available from within the command prompt. Instead, you first have to run another command prompt “As Administrator”, change to the right directory if necessary, and only then the elevated privileges are available for the desired command. This is a real impediment for often usage, and for some users it repeatedly leads to frustration about Windows in general.
You can learn a lot from Unix/Linux here: It implements the concept of separating users and administrators for a long time already and its tools are accordingly mature. You have the
sudo command available to execute single commands as administrator (root) or another user in a terminal, without interrupting your workflow. With no separate window and without leaving the current working directory.
UacConsole applies this principle to Windows. It uses the User Account Control and shows the respective dialog instead of asking for a password. After the confirmation, the specified command is executed in the current directory and the same console window with elevated privileges. All input and output goes in the active window as usual. You can for example also start another command prompt which will then have permanent elevated privileges.
Similar to sudo, the UAC confirmation can be cached for a while. This saves you from confirming the dialog for every single command. Therefore, a server process is started that handles further command requests for execution. It will terminate on its own after some idle time.
To execute a command with elevated privileges, simply prepend it with the command
uac. This starts UacConsole which will perform the necessary steps. The following call creates the directory AppDir in the current directory:
uac md AppDir
You can also start graphical applications this way, like a text editor to edit a protected file:
uac notepad File.txt
To disable the privilege caching for a command, use the option
/single or abbreviated
/s before the command:
uac /s dir
The caching timeout can also be configured by using the option
/it. With no further parameter, the current setting is displayed. Specify a new value in seconds to save it. The default timeout is 30 seconds. This setting is saved in the registry under HKLM\Software\Unclassified\UacConsole.
uac /it 300
To view the complete command description, start
uac without parameters or with
Note: Releases after 2016-01-09 are no longer digitally signed because there are no more free code signing certificates available for open source developers. A commercial certificate from 200 € per year doesn’t pay for me. I’m sorry for the confusion this may cause with your next download.
If UacConsole is not installed with the setup program, both program files must be copied into a directory from the search path, or their directory must be included in the search path (%PATH%) to allow an easy usage. Both program files must be in the same directory. The setup program copies the files into the Windows system directory.
This software is “freeware”. This means that it is free of charge for private and commercial use. Further distribution is prohibited without my permission. The source code is not available. There is no warranty, not even or merchantability for fitness for a particular purpose. I am not liable for any damage caused through appropriate or inappropriate use.
- Created on 2013-04-07.
- Ca. 530 lines of code, estimated development costs: 530 - 2 100 €