Stop CMD from always opening with administrator pr

2019-03-27 16:48发布

No matter how I open it, cmd.exe always opens with admin privileges. How can I open it without? Is there some registry setting missing? Even if I open it directly from the run dialog or by double clicking in the system32 folder it still opens with admin privs.

Thanks.

6条回答
Evening l夕情丶
2楼-- · 2019-03-27 17:23

Found a way to run as a specific user even when UAC is turned off from http://www.sevenforums.com/general-discussion/235987-run-cmd-exe-given-user-administrator-command-line.html

This is the way to start cmd.exe as any user. Replace "username" with the correct one:

cmd.exe> runas /user:username "cmd.exe"
查看更多
Anthone
3楼-- · 2019-03-27 17:24

Found out I was missing a registry key. In HKEY_CLASSES_ROOT\Directory\shell\cmd I was missing the String Value "Extended". Added this back in and restarted the machine got rid of the defaulting to admin privileges.

EDIT: I had UAC turned off for my profile (to stop incessant "are you sure you want to open this .exe" warnings), and turning that back on has stopped cmd always running with greater privileges.

查看更多
爷、活的狠高调
4楼-- · 2019-03-27 17:27

Right click on the cmd shortcut, navigate to properties, select advanced options and uncheck the 'Run as admin' option.

Check this video for better understanding - https://www.youtube.com/watch?v=3Mxh5TNSIl8&list=PLg8CURsOKswrzPs9fMhnmdy9TP7AkOOX1&index=1

查看更多
beautiful°
5楼-- · 2019-03-27 17:29

Right click on the cmd.exe, select properties and check the compatibility tab. Is the Run this program as an administrator checkbox checked?

查看更多
Lonely孤独者°
6楼-- · 2019-03-27 17:38

After some unclear actions (switch UAC on/off ?) I ended up in the same situation as described above:

  • Cmd.exe always starts in Adminstration mode.

  • Linking in VS failed with the message: Project : error PRJ0003 : Error spawning 'C:\windows\system32\cmd.exe'.

The Properties | Compatibility tab is greyed out, so switching this off seems impossible (Compatibility modes cannot be set on this program because it is part of this version of Windows).

To recover from this situation you have to edit the registry to remove the RUNASADMIN preferences that is associated with cmd.exe.

The 'RUNASADMIN' preference is stored in these registry keys:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

Delete the values named c:\windows\system32\cmd.exe and you are back in business !

Kees

查看更多
一夜七次
7楼-- · 2019-03-27 17:47

This is only happening because you're logged in as a user with administrative privileges.

Since doing so defeats the entire Windows security model, you shouldn't be doing that in the first place. Create a standard user account and log in with that, instead. The command prompt should then not open with administrative privileges since you don't have administrative privileges.

If, as a standard user, you need to open a command prompt with administrative privileges, you'll need to right-click on the shortcut and select the "Run as Administrator" option (just look for the UAC shield). You'll need to provide sufficient credentials to authenticate yourself as an administrator, and then you'll have the authority to wreak whatever havoc you wish.

查看更多
登录 后发表回答