如果您曾尝试在Windows PC 上(Windows)使用记事本编辑系统文件(edit a system file using Notepad),您可能会看到“记事本(Notepad)访问被拒绝”的错误消息。当您尝试从 PC 上的标准用户帐户修改系统文件时,通常会发生这种情况。Windows这样做是为了确保您的系统文件受到保护,并且只有管理员才能对它们进行更改。
如果您仍需要使用记事本(Notepad)访问和编辑文件,则需要以管理员身份打开记事本。(Notepad)然后,它应该为您提供修改计算机上任何系统文件所需的权限。有多种方法可以以管理员身份运行记事本(Notepad),在这里我们向您展示其中的一些。
使用右键菜单以管理员身份打开记事本(Open Notepad As Admin Using The Right-Click Menu)
以管理员身份运行记事本的最简单方法是使用上下文菜单中的选项。(Notepad)如果您曾经尝试以管理员身份运行应用程序,(running an app as an admin)那么您之前可能已经使用过此选项。
- 在您的机器上找到记事本应用程序。(Notepad)如果您经常使用它,它可能在您的桌面上。
- 右键单击(Right-click)该应用程序,然后选择Run as administrator选项。
- 系统将提示您输入管理员密码。输入密码并点击Yes。
记事本(Notepad)将以管理员权限启动,允许您修改系统上的任何文件。
通过创建快捷方式以管理员身份运行记事本(Run Notepad As Admin By Creating a Shortcut)
如果您需要过于频繁地以管理员权限运行记事本(Notepad),上述方法可能对您不方便。
幸运的是,有一种方法可以消除右键单击文件并自动启动具有管理员权限的记事本应用程序。(Notepad)不过,它每次都要求您输入管理员密码。
- 右键单击(Right-click)桌面上的空白处,然后选择新建(New),然后选择快捷方式(Shortcut)。它可以让你在桌面上添加一个新的快捷方式。
- 它会要求您输入要为其创建快捷方式的项目的位置。在框中键入以下内容并点击Next。这是记事本(Notepad)应用程序的路径。
%windir%\system32\notepad.exe
- 您现在将输入快捷方式的名称。这应该清楚地告诉您快捷方式的用途。我们建议使用带有 Admin 的记事本之(Notepad with Admin)类的东西。命名快捷方式后单击完成。(Finish)
- 新创建的快捷方式应该在您的桌面上可用。右键单击它并选择显示属性(Properties)的选项以授予它管理员权限。
- 前往快捷方式(Shortcut)选项卡,找到并单击高级(Advanced)按钮。
- 在接下来的屏幕上,勾选Run as administrator框,然后单击OK。
从现在开始,每当您双击新创建的快捷方式时,它都会以管理员权限打开记事本应用程序。(Notepad)
从 Cortana 搜索启动具有管理员权限的记事本(Launch Notepad With Admin Rights From Cortana Search)
Cortana搜索还允许您以管理员权限打开记事本实例。(Notepad)您基本上需要搜索该应用程序,然后选择一个启动它的选项。
- 将光标放在Cortana搜索框中并输入记事本(Notepad)。
- 当记事本(Notepad)出现在搜索结果中时,右键单击它并选择Run as administrator。
使用第三方应用访问具有管理员权限的记事本(Use A Third-Party App To Access Notepad With Admin Rights)
由于大多数用户更喜欢使用记事(Notepad)本来编辑系统文件,因此现在甚至有一个应用程序可以让您在每次打开此文本编辑器时以管理员身份运行它。
该应用程序名为RunAsTool,它允许您以管理员身份在计算机上运行任何应用程序。它可以免费下载和使用。
- 在您的 PC 上下载并启动RunAsTool 。它是便携式的,因此您无需安装它。
- 您将被要求选择您的管理员帐户。选择它,然后输入该帐户的密码。然后点击应用(Apply)继续。
- 单击顶部的文件菜单,然后选择(File)添加文件(Add File)。
- 导航到您的Windows文件夹,进入System32,然后双击Notepad.exe。
- 在应用程序中选择记事本(Notepad)并确保在右侧窗格中启用以管理员身份运行。(Run as administrator)
- 在应用程序中右键单击记事本(Notepad),然后选择创建快捷方式(Create Shortcut)。
双击这个新创建的快捷方式将在您的 PC 上以管理员身份启动记事本。(Notepad)它不会询问管理员密码,但会询问UAC权限。
在记事本中使用管理员权限直接打开文件(Directly Open Files With Admin Rights In Notepad)
如果您注意到,上述所有方法都要求您先打开记事本(Notepad)然后编辑文件。如果有一种方法可以让您使用管理员权限直接在记事本中打开要编辑的文件怎么办?(Notepad)嗯,有。
使用Windows注册表编辑器,您可以在右键菜单中添加一个选项(add an option to your right-click menu),让您可以使用管理员权限在记事本(Notepad)中打开任何文件。
- 在您的 PC 上登录(Sign-in)管理员帐户。同时按Windows + R键,输入regedit,然后按 Enter(Enter)。它将打开注册表编辑器。
- 在编辑器中访问以下路径。
HKEY_CLASSES_ROOT\*\shell
- 右键单击shell目录并选择New,然后选择Key以创建新密钥。
- 单击新创建的runas键,然后双击右侧窗格中的Default 。
- 键入Open in Notepad with Admin并按Enter。
- 通过右键单击runas并选择New然后选择Key在(Key)runas下创建一个新密钥。将此键命令(command)命名为。
- 双击命令键的(command)默认值(Default)并输入以下内容。将PCNAME替换为您的计算机名称。您的 PC 名称可以在Control Panel > System中找到。runas /savecred /user:PCNAME\Administrator “notepad %1”
- 现在右键单击要编辑的任何文件,然后选择Open in Notepad with Admin。
这只是一次性密码提示,下次使用该选项时不会要求您输入密码。
Open Notepad as Admin to Avoid “Access is Denied”
If you’ve ever tried to edit a system file using Notepad on your Windows PC, you’ve likely seen the error that says “Notepad access denied”. It usually happens when you try to modify a system file from a standard user account on a PC. Windows does this to ensure your system files are protected and that only the administrator can make changes to them.
If you still need to access and edit the file using Notepad, you’ll need to open Notepad as admin. It should then give you the privileges you need to modify any of the system files on your machine. There are multiple ways to run Notepad as admin and here we show you some of those.
Open Notepad As Admin Using The Right-Click Menu
The easiest way to run Notepad as an admin is to use an option from your context menu. You’ve likely used this option before if you’ve ever tried running an app as an admin.
- Locate the Notepad app on your machine. It may be on your desktop if you use it frequently.
- Right-click on the app and select the option that says Run as administrator.
- You’ll be prompted to enter your admin password. Enter the password and hit Yes.
Notepad will launch with admin privileges letting you modify any files on your system.
Run Notepad As Admin By Creating a Shortcut
The above method might not be convenient for you if you need to run the Notepad with admin privileges too frequently.
Fortunately, there’s a method that eliminates right-clicking on the file and automatically launches the Notepad app with admin rights. It’ll require you to input the admin password each time, though.
- Right-click anywhere blank on your desktop and choose New followed by Shortcut. It’ll let you add a new shortcut to your desktop.
- It’ll ask you to enter the location of the item that you want to create a shortcut for. Type the following into the box and hit Next. This is the path to the Notepad app.
%windir%\system32\notepad.exe
- You’ll now enter a name for your shortcut. This should be something that clearly tells you what the shortcut is for. We’d suggest using something like Notepad with Admin. Click on Finish when you’ve named your shortcut.
- The newly created shortcut should be available on your desktop. Right-click on it and select the option that says Properties to give it admin rights.
- Head to the Shortcut tab and find and click on the Advanced button.
- On the following screen, put a checkmark in the Run as administrator box and click on OK.
From now on, whenever you double-click on the newly created shortcut, it’ll open the Notepad app with admin rights.
Launch Notepad With Admin Rights From Cortana Search
Cortana search also allows you to open an instance of Notepad with admin rights. You basically need to search for the app and then choose an option that launches it.
- Put your cursor in the Cortana search box and type in Notepad.
- When Notepad appears in the search results, right-click on it and select Run as administrator.
- Enter your administrator password and the app will open.
Use A Third-Party App To Access Notepad With Admin Rights
Since most users prefer using Notepad to edit system files, there’s now even an app that lets you run this text editor as admin each time you open it.
The app’s called RunAsTool and it lets you run any app on your computer as an administrator. It’s available for free to download and use.
- Download and launch RunAsTool on your PC. It’s portable so you don’t need to install it.
- You’ll be asked to select your admin account. Select it and then enter the password for the account. Then hit Apply to continue.
- Click on the File menu at the top and select Add File.
- Navigate to your Windows folder, head into System32, and double-click on Notepad.exe.
- Select Notepad in the app and ensure Run as administrator is enabled in the right-hand side pane.
- Right-click on Notepad in the app and select Create Shortcut.
- Choose a location where you want to place the shortcut.
Double-clicking on this newly created shortcut will launch Notepad as admin on your PC. It won’t ask for an admin password but it will ask for UAC permissions.
Directly Open Files With Admin Rights In Notepad
If you’ve noticed, all of the methods above require you to first open Notepad to then edit your files. What if there was a way you could directly open the files you want to edit in Notepad with the admin rights? Well, there is.
Using Windows registry editor, you can add an option to your right-click menu that lets you open any of your files in Notepad with administrator privileges.
- Sign-in to an admin account on your PC. Press the Windows + R keys at the same time, type in regedit, and hit Enter. It’ll open registry editor.
- Access the following path in the editor.
HKEY_CLASSES_ROOT\*\shell
- Right-click on the shell directory and select New followed by Key to create a new key.
- Enter runas as the name of the key.
- Click on the newly created runas key and then double-click on Default in the right-hand side pane.
- Type Open in Notepad with Admin and press Enter.
- Create a new key under runas by right-clicking on runas and selecting New followed by Key. Name this key command.
- Double-click on Default for the command key and enter in the following. Replace PCNAME with your computer’s name. Your PC name can be found in Control Panel > System.
runas /savecred /user:PCNAME\Administrator “notepad %1”
- Now right-click on any file you want to edit and select Open in Notepad with Admin.
- You’ll be asked to enter your admin password.
It’s only a one-time password prompt and you won’t be asked to enter the password the next time you use the option.