How can I always run the command prompt as administrator?
2013-05-16 15:40
369 查看
To do this, paste the following into notepad and save it with a ".reg" extension:
Then run the file. It will merge the changes into the registry and add the option to your context menus of any folder.
Many programs let you permanently change their default privilege level from the Properties menu. Command Prompt is not one of those programs.
The Compatibility tab is completely disabled for all of
Windows’ executables:
To set admin privileges for Windows executables, you need to create a shortcut and use Shortcuttab→
command-prompt item in the Start menu is already a shortcut):
The window always opens in C:\windows\system32, rather than my Users directory (as in approved technique 1) or the folder I want to be in (as in approved technique 2). So I often have to change directories to get where I want to
go.
That is normal and makes sense since if you are opening an admin command-prompt, you are probably doing some system actions for which you need admin privileges instead of user actions that you already have permissions for anyway.
You can set the default directory globally by adding/editing the
entry (it does not even have to be an expandable string to use environment variables):
Now, any time you open a command-prompt using any method will automatically default (well, technicallychange-directory)
to your user-profile directory.
Even better, you can add other commands to be automatically run whenever you open a command-prompt using the
(e.g.,
to set it for all users.
Note that you will still have to accept the UAC prompt. Unfortunately there is (currently?) no way to create a UAC “whitelist” of trusted programs so that the command-prompt can be run as admin without having to accept the prompt. This leaves you with (a) few
options.
You can turn UAC down or off altogether (
You can use a privilege-elevation program like Elevator
aka Elevate Me or the Elevation
PowerToy
Create an elevated scheduled task,
enter the credentials (once) for it, and then create a shortcut to the task
In the first case, you avoid the UAC altogether while in the latter two, you only enter your credentials once when creating the shortcut.
Referenced from: http://superuser.com/questions/453409/how-can-i-always-run-the-command-prompt-as-administrator
[code]Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\runas] @="Open Command Window Here as Administrator" [HKEY_CLASSES_ROOT\Directory\shell\runas\command] @="cmd.exe /s /k pushd \"%V\""
Then run the file. It will merge the changes into the registry and add the option to your context menus of any folder.
Many programs let you permanently change their default privilege level from the Properties menu. Command Prompt is not one of those programs.
The Compatibility tab is completely disabled for all of
Windows’ executables:
To set admin privileges for Windows executables, you need to create a shortcut and use Shortcuttab→
Advanced(the
command-prompt item in the Start menu is already a shortcut):
The window always opens in C:\windows\system32, rather than my Users directory (as in approved technique 1) or the folder I want to be in (as in approved technique 2). So I often have to change directories to get where I want to
go.
That is normal and makes sense since if you are opening an admin command-prompt, you are probably doing some system actions for which you need admin privileges instead of user actions that you already have permissions for anyway.
You can set the default directory globally by adding/editing the
Autorunregistry
entry (it does not even have to be an expandable string to use environment variables):
[code]REGEDIT4 [HKEY_CURRENT_USER\Software\Microsoft\Command Processor] "Autorun"="cd /d \"%userprofile%\""
Now, any time you open a command-prompt using any method will automatically default (well, technicallychange-directory)
to your user-profile directory.
Even better, you can add other commands to be automatically run whenever you open a command-prompt using the
&operator
(e.g.,
cd /d %userprofile% & cls & dir). In addition, you can set the same value in the same key under the
HKLMbranch
to set it for all users.
Note that you will still have to accept the UAC prompt. Unfortunately there is (currently?) no way to create a UAC “whitelist” of trusted programs so that the command-prompt can be run as admin without having to accept the prompt. This leaves you with (a) few
options.
You can turn UAC down or off altogether (
useraccountcontrolsettings.exe)
You can use a privilege-elevation program like Elevator
aka Elevate Me or the Elevation
PowerToy
Create an elevated scheduled task,
enter the credentials (once) for it, and then create a shortcut to the task
In the first case, you avoid the UAC altogether while in the latter two, you only enter your credentials once when creating the shortcut.
Referenced from: http://superuser.com/questions/453409/how-can-i-always-run-the-command-prompt-as-administrator
相关文章推荐
- How can I add a new user as sudoer using the command line?
- How to Run a Program as an Administrator in Windows 7
- 053-23 How can you reverse the effects of an ALTER DISKGROUP … DROP DISK command if it has not yet c
- [转]How do I run msbuild from the command line using Windows SDK 7.1?
- 【DB2】If 'db2' is not a typo you can run the following command to lookup the package that contains the binary: command-not-found db2 bash: db2: command not found
- How can I run two Django versions in the same server?
- mysql多实例配置下,用脚本启动mysql时,出现Please read "Security" section of the manual to find out how to run mysqld as root!
- [Tip]Always Quote the commandline arguments that can possibly contain whitespaces
- 23 How can you reverse the effects of an ALTER DISKGROUP … DROP DISK command if it has not yet compl
- [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as r
- A child is running up a staircase with N steps, and can hop either 1 step,2steps,3 steps at a time. Count how many possible ways the child can run up
- How to Run a Program as an Administrator in Windows 7
- Please read "Security" section of the manual to find out how to run mysqld as root!错误解决
- How to Run a Program as an Administrator in Windows 7
- How can I run Perl system commands in the background
- How the bgp deterministic-med Command Differs from the bgp always-compare-med Command
- How to run application in Qt as administrator?
- How PowerShell Differs From the Windows Command Prompt
- Android - How to direct the audio data from MediaRecorder as the input of ffmpeg command via Pipe?
- [Yii Framework] How to run cron job (or use command) in the server with yii framework