Windows 10: Open Notepad as Administrator with Context Menu? Solved

Page 1 of 2 12 LastLast
  1.    01 Jun 2017 #1

    Open Notepad as Administrator with Context Menu?


    I'm often having to edit batch files in my C: drive or my windows hosts files and forever running into access permissions issues.

    I've seen a few posts showing how you can make a registry style hack to add a right-click option to open a file as notepad as admin, but none of them seem to work in Windows 10?

    Here's the code that I found to create an .inf file to do this for Win8 (it doesn't work for me in Win10). I'm wondering if any gurus here could help me modify it to work on Windows 10?

    Code:
    [version]Signature="$Windows NT$"Class="Open in Notepad As Admin for Win8.1"Provider="%Microsoft%"
    [OpeninNotepadAsAdminInstall]CopyFiles = OpeninNotepadAsAdmin.Files.InfAddReg    = OpeninNotepadAsAdmin.AddReg
    [DefaultInstall]
    CopyFiles = OpeninNotepadAsAdmin.Files.Inf
    AddReg    = OpeninNotepadAsAdmin.AddReg
    
    [DefaultUnInstall]
    DelFiles  = OpeninNotepadAsAdmin.Files.Inf
    DelReg    = OpeninNotepadAsAdmin.DelReg
    
    [SourceDisksNames]
    55="Open in Notepad as Admin","",1
    
    [SourceDisksFiles]
    OpeninNotepadAsAdmin.INF=55
    
    [DestinationDirs]
    OpeninNotepadAsAdmin.Files.Inf = 17
    
    [OpeninNotepadAsAdmin.Files.Inf]
    OpeninNotepadAsAdmin.INF
    
    [OpeninNotepadAsAdmin.AddReg]
    HKLM,%UDHERE%,DisplayName,,"%OpeninNotepadAsAdminName%"
    HKLM,%UDHERE%,DisplayIcon,,"C:\Windows\notepad.exe,0"
    HKLM,%UDHERE%,DisplayVersion,,"%DisplayVersion%"
    HKLM,%UDHERE%,DisplayPublisher,,"%DisplayPublisher%"
    HKLM,%UDHERE%,DisplaySize,,"%DisplaySize%"
    HKLM,%UDHERE%,UninstallString,,"rundll32.exe syssetup.dll, SetupInfObjectInstallAction DefaultUninstall 132 %17%\OpeninNotepadAsAdmin.inf"
    HKCR,*\Shell\runas,,,"%OpeninNotepadAsAdminAccel%"
    HKCR,*\Shell\runas,Icon,,"C:\\Windows\\system32\\notepad.exe,0"
    HKCR,*\Shell\runas\command,,,"%11%\notepad.exe ""%1"""
    HKCU,%IEHERE%,Secondary Start Pages,0x00010008,"%DisplayURL%";FLG_ADDREG_TYPE_MULTI_SZ | FLG_ADDREG_APPEND
    
    [OpeninNotepadAsAdmin.DelReg]
    HKLM,%UDHERE%HKCR,*\shell\runas
    HKCR,Directory\Shell\runas
    HKCR,Drive\Shell\runas;
    HKCU,%IEHERE%,Secondary Start Pages,0x00010020,"%DisplayURL%"; did not work to uninstall website, removed all 2nd websites now way to save what you had
    
    [Strings]
    DisplayPublisher = "Microsoft"
    OpeninNotepadAsAdminName="Open in Notepad as Admin [by MetadataConsulting.ca](Uninstall only)"
    DisplayVersion = "2014.04.27"
    DisplaySize = "4 Kb"
    DisplayURL = "http://metadataconsulting.blogspot.ca/"
    OpeninNotepadAsAdminAccel="Open in Notepad as Admin"
    UDHERE="Software\Microsoft\Windows\CurrentVersion\Uninstall\OpeninNotepadAsAdmin"
    IEHERE="Software\Microsoft\Internet Explorer\Main"
      My ComputerSystem Spec

  2.    01 Jun 2017 #2

    Hosts file: try Bluelife HostsEditor
    BlueLife Hosts Editor Download
    - no permissions issues. Freeware
      My ComputerSystem Spec


  3. Posts : 3,922
    Win10 Home and Pro, Win10 Insider Preview, Win7 Home, Linux Mint
       01 Jun 2017 #3

    Don't know if it's what you are looking for but I right-clicked the Desktop, chose New, Shortcut then located notepad.exe in the C:\Windows Folder and finished. Then I right-clicked the shortcut, Properties and in the Shortcut tab clicked Advanced then put a checkmark in Run as Administrator. As has been noted various places since Win10 came out, can't do much with icons on the Start menu or the Tiles but once the Shortcut has been created you can do more with it.
      My ComputerSystem Spec


  4. Posts : 8,721
    windows 10 professional version 1607 build 14393.969 64 bit
       01 Jun 2017 #4

    See if these command lines/ methods work:

    1) Open administrative command prompt and type or copy and paste:

    runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc
    runas /noprofile /user:mymachine\administrator cmd

    2) Type notepad in the left lower corner search then right click on the best match notepad and run as administrator


    3) This one is similar to Berton's method above except you type the location
    Right click on the desktop and hover over new and select shortcut
    Type the location: %windir%\System32\notepad.exe
    next
    choose the name: Notepad
    Finish
    Right click on the short cut, click properties, click advanced, check run as administrator
    With the shortcut on the desktop it is left click opened automatically as administrator.
      My ComputerSystem Spec


  5. Posts : 12,968
    Windows 10 Pro
       01 Jun 2017 #5

    Berton said: View Post
    As has been noted various places since Win10 came out, can't do much with icons on the Start menu or the Tiles .
    I have not nor have I had any issues in running any app elevated (including Notepad) from Start Menu or Start tile.

    Click image for larger version. 

Name:	image.png 
Views:	45 
Size:	217.8 KB 
ID:	137649
      My ComputerSystem Spec

  6.    02 Jun 2017 #6

    These are all good suggestions, but not quite what I was hoping to achieve.

    Given the number of times I need to edit a host file or some of my custom .bat files located in various locations that might have protected permissions that prevent saving updated files, I was trying to find a context-menu driven option. Since I do this with a high-degree of frequency it's annoying having to open notepad and then use the Open menu option and navigate to the files I'm trying to work on.

    The other option is to use Notepad++ with the plugin for saving as an admin to get right-click edit/save options. I just saw this script that worked in Win8 and thought that maybe I could tweak/fix it and get it working in Win10 without having to go for a third-party software solution.
      My ComputerSystem Spec


  7. Posts : 3,922
    Win10 Home and Pro, Win10 Insider Preview, Win7 Home, Linux Mint
       02 Jun 2017 #7

    On my computers the .txt files when double-clicked will open in Notepad by default. Can't do that with .bat file as double-clicking them will cause them do what they are programmed to do. Right-clicking a .bat file and choosing Edit lets me do it. I've been doing that way when needed since back in MS-DOS 5 and Windows 3.1 days. I'm sure an appropriate script will work but since I've quit programming I like simpler.
      My ComputerSystem Spec

  8.    02 Jun 2017 #8

    Ok, here's a way to do it using Autohotkey.

    1. write an AHK script like this:
    Run, *runas notepad.exe %1%
    exit
    2. Compile it to e.g. Notepad admin.exe
    3. Using e.g. this program (for convenience) do this:
    Click image for larger version. 

Name:	Snap 2017-06-02 at 08.45.41.jpg 
Views:	3 
Size:	76.5 KB 
ID:	137674
    to add the compiled program to the context menu.
    (Sorry, I realise that prog is not free... there are others or you can achieve the same using regedit or the venerable Contextedit etc).

    (Here I've added it for all files- you can choose which one or ones you want).

    Now right clicking a file and clicking 'Notepad admin'
    Click image for larger version. 

Name:	Untitled.png 
Views:	44 
Size:	26.8 KB 
ID:	137675

    gives a UAC prompt ('cos Notepad's run as admin) and opens your file.
    Last edited by dalchina; 4 Weeks Ago at 00:39.
      My ComputerSystem Spec

  9.    02 Jun 2017 #9

    Genius, Dalchina. Works a treat. Even works properly after I replace notepad with notepad2! Thank you!
      My ComputerSystem Spec

  10.    03 Jun 2017 #10

    Well done for understanding that!
      My ComputerSystem Spec


 
Page 1 of 2 12 LastLast

Related Threads
How to Add or Remove 'Run as administrator' Context Menu in Windows 10 Some legitimate applications require a full administrator access token (elevated) to perform their functions or tasks. For example, when a program that you are trying to run...
How to Add or Remove 'Open with Notepad' Context Menu in Windows 10 Adding "Open with Notepad" to the context menu of all files will allow you to quickly open that file with Notepad without setting Notepad to be the default app for that file...
How to Add 'Run as administrator' to MSI File Context Menu in Windows 10 Some legitimate applications require a full administrator access token (elevated) to perform their functions or tasks. For example, when a program that you are trying to run...
How to Add 'Run as administrator' to VBS File Context Menu in Windows 10 Some legitimate applications require a full administrator access token (elevated) to perform their functions or tasks. For example, when a program that you are trying to run...
;notepad @="\"notepad.exe %1\"" @="Open &With Notepad" @="notepad.exe %1" the above dont seem to give me open with notepad in context menu unlike in win7. any ideas?
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:12.
Find Us