如果您在命令提示符(running commands in Command Prompt)或Windows PowerShell中运行命令时反复看到“(Windows PowerShell)系统(System)错误 5 已发生,访问(Access)被拒绝” ,则可能是控制台缺少执行这些命令所需的权限。例如,涉及管理功能(如“net user”)或高级故障排除(advanced troubleshooting)的命令需要增强权限或不起作用。
要修复Microsoft Windows中的“系统错误 5” ,您必须以管理员身份运行命令提示符(Command Prompt)和Windows PowerShell 。下面的说明将引导您通过多种方式打开具有提升权限的两个命令行解释器。
(Run Command Prompt)以管理员身份(Administrator)运行命令提示符和Windows PowerShell
使用默认用户权限在命令提示符(Command Prompt)或Windows PowerShell中运行命令是不可能的。如果命令输出导致“系统(System)错误 5”,您必须以管理员身份启动首选的命令行解释器。
以管理员身份打开命令提示符(Open Command Prompt as Administrator)
1. 打开开始(Start )菜单(或按Windows键)并键入cmd或命令提示符(command prompt)。
2.在搜索结果中选择以管理员身份运行选项。(Run as administrator)
3.在用户帐户控制(User Account Control)( UAC ) 对话框中选择是。(Yes )
注意:(Note:) Windows 7中不存在用户帐户控制(User Account Control)。
然后,您将在标题栏上看到带有“管理员”标签的命令提示符窗口。(Command Prompt)执行命令时不会再遇到“系统(System)错误 5”。
以管理员身份打开命令提示符的更快方法是在“(Command Prompt)开始(Start)”菜单上搜索命令提示符后立即按Ctrl + Shift + Enter 。
以管理员身份打开 Windows PowerShell(Open Windows PowerShell as Administrator)
Windows 10和 11都具有通过Windows + X(又名Power User)菜单以管理员身份打开Windows PowerShell的选项。(Windows PowerShell)
1. 按Windows + X或右键单击开始(Start )按钮。
2. 选择Windows 终端(管理员)(Windows Terminal (Admin))或Windows PowerShell(管理员)(Windows PowerShell (Admin))。
3.在用户帐户控制(User Account Control)( UAC ) 提示中选择是。(Yes )
然后,您将看到带有“管理员”标签的Windows PowerShell窗口(或选项卡,如果控制台通过Windows 终端启动)。(Windows Terminal)在其中执行命令时不会出现“系统错误5”。(System)
或者,您可以在开始(Start )菜单上搜索powershell并选择以管理员身份运行(Run as administrator)或按Ctrl + Shift + Enter打开提升的Windows PowerShell窗口。
提示(Tip):了解如何在 Windows 10 高级用户菜单上将Windows PowerShell 替换为命令提示符(replace Windows PowerShell with Command Prompt)。
始终运行(Run)提升的命令提示符(Elevated Command Prompt)和Windows PowerShell 控制台(Windows PowerShell Console)
可以在Windows(Windows)中构建能够以管理员身份自动打开命令提示符(Command Prompt)或Windows PowerShell的桌面快捷方式。(Windows PowerShell)这消除了错误启动具有标准用户权限的控制台并遇到“系统(System)错误 5”的机会。
1. 根据您要创建快捷方式的命令行解释器,打开文件资源管理器(File Explorer)窗口并转到相关目录:
命令提示符 -本地磁盘 C(Local Disk C) > Windows > System32
Windows PowerShell -本地磁盘 C(Local Disk C) > Windows > System32 > WindowsPowerShell > v1.0
2. 找到标有cmd(命令提示符)或powershell ( Windows PowerShell ) 的文件。然后,右键单击它并选择Show more options (Windows 11 only) > Send to > Desktop (create shortcut)。
3、右键单击桌面上新创建的cmd-快捷方式(cmd – Shortcut)或powershell-快捷方式图标。(powershell – Shortcut)然后,选择属性(Properties)。
4. 在快捷方式(Shortcut )选项卡下,选择高级(Advanced)。
5. 选中以管理员(Run as administrator)身份运行旁边的框,然后选择确定(OK)。
6. 选择应用(Apply )和确定(OK )退出属性框。
您现在可以双击快捷方式并在UAC弹出窗口上选择是(Yes ),以使用管理权限打开命令提示符(Command Prompt)或Windows PowerShell 。随意(Feel)将快捷方式重命名为您喜欢的任何名称。
禁用命令提示符(Command Prompt)和Windows PowerShell的UAC 提示(UAC Prompts)
用户帐户控制 (UAC)(User Account Control (UAC))是Windows Vista、8、8.1、10 和 11 中的一项安全功能,可防止程序未经许可对系统进行更改。但是,每次您想以管理员权限打开命令提示符(Command Prompt)或Windows PowerShell时处理UAC提示会分散注意力。(UAC)
解决这个问题的最快方法是完全禁用UAC。但是,这会带来重大的安全风险。或者,您可以仅针对Command Prompt(Command Prompt)或Windows PowerShell绕过提示。这更安全,但需要时间来设置。
完全禁用用户帐户控制(Disable User Account Control Completely)
1.在开始(Start)菜单上搜索uac并选择打开(Open)以启动用户帐户控制设置(User Account Control Settings)对话框。
2. 将滑块拖动到从不通知(Never notify)。
3. 选择确定(OK)以在系统范围内停用用户帐户控制(User Account Control)。
要稍后重新激活UAC,只需执行上述步骤并将滑块拖动到第一个或第二个槽口。
提示:(Tip:)您还可以通过在控制面板上选择(Control Panel)系统和安全(System and Security)>更改用户帐户控制设置来访问(Change User Account Control settings)用户帐户控制设置(User Account Control Settings)对话框。
仅针对命令提示符和 Windows PowerShell 绕过 UAC(Bypass UAC for Command Prompt and Windows PowerShell Only)
1.在开始(Start)菜单中搜索schtasks ,然后按(schtasks)Enter启动任务计划程序。
2. 右键单击侧栏上的任务计划程序库(Task Scheduler Library),然后选择新建文件夹(New Folder)。
3. 输入文件夹的名称,例如No UAC。
4. 选择侧边栏上新创建的文件夹,然后选择创建任务( Create Task)。
5. 为任务命名—例如,命令提示符(管理员)并选中(Command Prompt (Admin))以最高权限运行(Run with highest privileges)旁边的框。
6. 切换到操作(Actions )选项卡并选择新建(New)。
7. 将操作(Action)设置为启动程序(Start a program)并粘贴命令提示符(Command Prompt)或Windows PowerShell可执行文件的文件路径:
命令提示符 - C:\Windows\System32\cmd.exe
Windows PowerShell — C:\Windows\System32\WindowsPowerShell\v1.0
9. 切换到条件(Conditions)选项卡并取消选中仅当计算机处于交流电源时才启动任务(Start the task only if the computer is on AC power)。然后,选择确定(OK)以保存任务。
10. 右键单击桌面中的空白区域并选择新建(New)>快捷方式(Shortcut)。
11. 输入以下路径,将文件夹名称(Folder name)和任务名称( Task name )替换为您在创建任务时插入的名称:
C:\Windows\System32\schtasks.exe /RUN /TN “Folder name\Task name”
选择下一步(Next)继续。
12. 输入快捷方式的名称并选择完成(Finish)。
13. 双击您刚刚创建的桌面上的快捷方式,一个新的提升的命令提示符(Command Prompt)或Windows PowerShell控制台将在没有UAC提示的情况下启动。
修复(Fix System Error 5)标准 Windows(Standard Windows)帐户上的系统错误 5
假设(Suppose)您在 PC 上的非管理员帐户中遇到“系统错误 5 已发生”。(System)在这种情况下,您仍然可以使用上述说明通过插入管理员密码来运行增强的命令提示符(Command Prompt)或Windows PowerShell控制台。(Windows PowerShell)如果您不知道,请向具有 PC 管理权限的用户请求许可。
或者,您可以将标准帐户更改为管理员帐户(change a standard account to an admin account)(假设您是 PC 的所有者),以避免每次要打开具有提升权限的命令行解释器时都必须输入管理员密码。以下步骤适用于Windows 10和 11。
1. 登录您的管理员帐户,然后选择开始(Start)>设置(Settings )>帐户(Accounts)>家庭和其他用户(Family & other users)。
2. 在其他用户(Other users)下选择标准账户,然后选择更改账户类型(Change account type)。
3. 将帐户类型(Account type)设置为管理员(Administrator ),然后选择确定(OK)。
已(Has)修复:未发生系统错误 5(System Error 5)
重申一下,只需以管理员身份运行命令提示符(Command Prompt)和Windows PowerShell即可修复(Windows PowerShell)Microsoft Windows中的“(Microsoft Windows)系统(System)错误 5”错误代码。如果您经常使用这两个控制台,那么花时间设置始终以提升的权限启动它们的快捷方式(最好没有烦人的用户帐户控制(User Account Control)提示来处理)从长远来看可能会节省数小时。
Fix System Error 5, Access is Denied in Windows
If you keep seeing “Ѕystem error 5 hаs occurrеd, Access is denied” repeatedly while running commands in Command Prompt or Windows PowerShell, it’s likely that the console lacks the rights needed to execute them. For example, commands involving administrative functions (such as “net user”) or advanced troubleshooting require enhanced privileges or won’t work.
To fix “System error 5” in Microsoft Windows, you must run Command Prompt and Windows PowerShell as an administrator. The instructions below will walk you through multiple ways to open both command-line interpreters with elevated rights.
Run Command Prompt and Windows PowerShell as Administrator
It’s impossible to run commands in Command Prompt or Windows PowerShell with default user privileges. If the command output results in “System error 5,” you must launch your preferred command-line interpreter as an administrator.
Open Command Prompt as Administrator
1. Open the Start menu (or press the Windows key) and type cmd or command prompt.
2. Select the Run as administrator option in the search results.
3. Select Yes on the User Account Control (UAC) dialog box.
Note: User Account Control is not present in Windows 7.
You will then see a Command Prompt window with the “Administrator” label on the title bar. You won’t encounter the “System error 5” while executing commands anymore.
A faster way to open Command Prompt as an administrator involves pressing Ctrl + Shift + Enter immediately after searching for it on the Start menu.
Open Windows PowerShell as Administrator
Both Windows 10 and 11 feature the option to open Windows PowerShell as an administrator via the Windows + X (a.k.a. Power User) menu.
1. Press Windows + X or right-click the Start button.
2. Select Windows Terminal (Admin) or Windows PowerShell (Admin).
3. Select Yes on the User Account Control (UAC) prompt.
You will then see a Windows PowerShell window (or tab if the console launches via Windows Terminal) with the “Administrator” label. “System error 5” will not show up while executing commands in it.
Alternatively, you can search for powershell on the Start menu and select Run as administrator or press Ctrl + Shift + Enter to open an elevated Windows PowerShell window.
Tip: Learn how to replace Windows PowerShell with Command Prompt on the Windows 10 Power User menu.
Always Run an Elevated Command Prompt and Windows PowerShell Console
It’s possible to build a desktop shortcut in Windows capable of automatically opening Command Prompt or Windows PowerShell as an administrator. That eliminates the chances of mistakenly launching a console with standard user privileges and encountering “System error 5.”
1. Depending on the command-line interpreter you want to create a shortcut to, open a File Explorer window and head over to the relevant directory:
Command Prompt — Local Disk C > Windows > System32
Windows PowerShell — Local Disk C > Windows > System32 > WindowsPowerShell > v1.0
2. Locate the file labeled cmd (Command Prompt) or powershell (Windows PowerShell). Then, right-click it and select Show more options (Windows 11 only) > Send to > Desktop (create shortcut).
3. Right-click the newly created cmd – Shortcut or powershell – Shortcut icon on the desktop. Then, select Properties.
4. Under the Shortcut tab, select Advanced.
5. Check the box next to Run as administrator and select OK.
6. Select Apply and OK to exit the Properties box.
You can now double-click the shortcut and select Yes on the UAC pop-up to open Command Prompt or Windows PowerShell with administrative privileges. Feel free to rename the shortcut to whatever you like.
Disable UAC Prompts for Command Prompt and Windows PowerShell
User Account Control (UAC) is a security feature in Windows Vista, 8, 8.1, 10, and 11 that prevents programs from making changes to the system without permission. However, dealing with UAC prompts each time you want to open Command Prompt or Windows PowerShell with admin rights is distractive.
The quickest way to deal with that is to disable UAC altogether. However, that poses a significant security risk. Or, you can bypass the prompt only for Command Prompt or Windows PowerShell. That’s safer but takes time to set up.
Disable User Account Control Completely
1. Search for uac on the Start menu and select Open to launch the User Account Control Settings dialog.
2. Drag the slider to Never notify.
3. Select OK to deactivate User Account Control system-wide.
To re-activate UAC later, simply go through the steps above and drag the slider to the first or second notch.
Tip: You can also reach the User Account Control Settings dialog by selecting System and Security > Change User Account Control settings on the Control Panel.
Bypass UAC for Command Prompt and Windows PowerShell Only
1. Search for schtasks on the Start menu and press Enter to launch the Task Scheduler.
2. Right-click Task Scheduler Library on the sidebar and select New Folder.
3. Enter a name for the folder—e.g., No UAC.
4. Select the newly-created folder on the sidebar and select Create Task.
5. Name the task—e.g., Command Prompt (Admin) and check the box next to Run with highest privileges.
6. Switch to the Actions tab and select New.
7. Set Action to Start a program and paste in the file path for the Command Prompt or Windows PowerShell executable:
Command Prompt — C:\Windows\System32\cmd.exe
Windows PowerShell — C:\Windows\System32\WindowsPowerShell\v1.0
9. Switch to the Conditions tab and uncheck Start the task only if the computer is on AC power. Then, select OK to save the task.
10. Right-click a vacant area within the desktop and select New > Shortcut.
11. Enter the following path, replacing Folder name and Task name with the names that you inserted while creating the task:
C:\Windows\System32\schtasks.exe /RUN /TN “Folder name\Task name”
Select Next to continue.
12. Type in a name for the shortcut and select Finish.
13. Double-click the shortcut on the desktop that you just created, and a new elevated Command Prompt or Windows PowerShell console will launch without a UAC prompt.
Fix System Error 5 on Standard Windows Accounts
Suppose you encounter “System error 5 has occurred” in a non-administrator account on your PC. In that case, you can still run an enhanced Command Prompt or Windows PowerShell console using the instructions above by inserting an administrator password. If you don’t know it, ask for permission from a user with administrative privileges to the PC.
Alternatively, you can change a standard account to an admin account (assuming that you’re the owner of your PC) to avoid having to type in an administrator password each time you want to open a command-line interpreter with elevated rights. The steps below apply to Windows 10 and 11.
1. Sign in to your administrator account and select Start > Settings > Accounts > Family & other users.
2. Select the standard account under Other users and select Change account type.
3. Set Account type to Administrator and select OK.
Fixed: System Error 5 Has Not Occurred
To reiterate, simply running Command Prompt and Windows PowerShell as an administrator will fix the “System error 5” error code in Microsoft Windows. If you use both consoles regularly, taking the time to set up shortcuts that always launch them with elevated privileges (preferably without an annoying User Account Control prompt to deal with) will likely save hours in the long run.