Launch UltraEdit as administrator in Windows 7 when right click files

Launch UltraEdit as administrator in Windows 7 when right click files

2

    May 25, 2012#1

    The other day I wanted to edit a file in a 'protected system folder'.
    I.e. this file: C:\Windows\System32\drivers\etc\hosts
    As I usually do, I right-clicked the file in Windows Explorer and opened it in UltraEdit.
    However I couldn't then save it (due to the Windows 7 UAC intervening).

    I found this post...
    How to Add an "Open With Notepad As Administrator" Shortcut to the Context Menu in Windows 7 and Windows Vista
    which explains how to add a 'run notepad as administrator' item to the windows explorer context menu.

    Is there a similar way to add a Windows Explorer context menu item to run ultraedit as administrator?

    (I know there are alternative ways of doing this such as turning off the UAC or launching UltraEdit as an administrator from the Windows start menu, but this is not what I want.)

    I'm on Windows 7 64-bit, UltraEdit 15.

    Thanks

    6,688586
    Grand MasterGrand Master
    6,688586

      May 26, 2012#2

      Well, without testing it, it should be quite easy to add UltraEdit as Admin using the template INF data posted in the referenced article.

      I simply have replaced all occurrences of Notepad by UltraEdit. The red formated text must be replaced by real program files path of UltraEdit on your computer. You can copy the path from the shortcut used usually to start UltraEdit in start menu or on desktop.

      I have added /fni command line parameter to force always a new instance as UltraEdit may already run with current user permissions and configuration setting Allow multiple instances is not enabled. Starting UltraEdit with Administrator privileges requires starting UltraEdit in a new instance.

      Save the file as UltraEditAsAdmin.inf.

      Right click the file and select Install.

      To try it, right click any file in Windows Explorer and you should see a new menu item called UltraEdit as Admin.

      To remove the menu item again, just go to the list of installed software in the Control Panel and uninstall the entry called UltraEdit as Admin PowerToy (Uninstall only).

      [version]
      signature="$CHICAGO$"

      [UltraEditAsAdminInstall]
      CopyFiles = UltraEditAsAdmin.Files.Inf
      AddReg = UltraEditAsAdmin.AddReg

      [DefaultInstall]
      CopyFiles = UltraEditAsAdmin.Files.Inf
      AddReg = UltraEditAsAdmin.AddReg

      [DefaultUnInstall]
      DelFiles = UltraEditAsAdmin.Files.Inf
      DelReg = UltraEditAsAdmin.DelReg

      [SourceDisksNames]
      55="UltraEdit as Admin","",1

      [SourceDisksFiles]
      UltraEditAsAdmin.INF=55

      [DestinationDirs]
      UltraEditAsAdmin.Files.Inf = 17

      [UltraEditAsAdmin.Files.Inf]
      UltraEditAsAdmin.INF

      [UltraEditAsAdmin.AddReg]
      HKLM,%UDHERE%,DisplayName,,"%UltraEditAsAdminName%"
      HKLM,%UDHERE%,UninstallString,,"rundll32.exe syssetup.dll, SetupInfObjectInstallAction DefaultUninstall 132 %17%\UltraEditAsAdmin.inf"
      HKCR,*\shell\runas,,,"%UltraEditAsAdminAccel%"
      HKCR,*\shell\runas\command,,,"""Path to UltraEdit program files directory\uedit32.exe"" /fni ""%1"""

      [UltraEditAsAdmin.DelReg]
      HKLM,%UDHERE%
      HKCR,*\shell\runas

      [Strings]
      UltraEditAsAdminName="UltraEdit as Admin PowerToy (Uninstall only)"
      UltraEditAsAdminAccel="UltraEdit as Admin"
      UDHERE="Software\Microsoft\Windows\CurrentVersion\Uninstall\UltraEditAsAdmin"

      2

        May 26, 2012#3

        Thanks Mofi, that worked. Unfortunately it seems to overwrite the 'notepad as admin' option - but can live without that. (I didnt want to fiddle about too much incase I break something.)

        6,688586
        Grand MasterGrand Master
        6,688586

          May 27, 2012#4

          I tested the INF now and found out that uninstall did not remove both added registry keys correct, a mistake of the template. I corrected the INF file in above post.

          Also the registration of the only key needed could be done with copying and pasting following into a plain text file, save it as UltraEditAsAdmin.reg and double click on this registry file to import the data inside to the Windows registry.

          REGEDIT4

          [HKEY_LOCAL_MACHINE\Software\Classes\*\shell\runas]
          @="UltraEdit as Admin"

          [HKEY_LOCAL_MACHINE\Software\Classes\*\shell\runas\command]
          @="\"
          Path to UltraEdit program files directory\\uedit32.exe\" /fni \"%1\""

          Every backslash in the path must be escaped with an additional backslash.

          That simplified method would result in no additional files stored on hard disk as the INF solution results in. (For example automatically created UltraEditAsAdmin.pnf is not removed in INF folder of Windows after uninstall and the INF file is just moved to INF directory in LastGood directory in Windows directory on uninstall instead of being deleted completely.) This registration key can be removed with a *.reg file containing following:

          REGEDIT4

          [-HKEY_LOCAL_MACHINE\Software\Classes\*\shell\runas]


          Or for removing entire key shell if this key was not present already before adding runas and therefore not containing anything else than just the subkey runas:

          REGEDIT4

          [-HKEY_LOCAL_MACHINE\Software\Classes\*\shell]


          Adding the Run As command for all files in HKLM with INF or REG file for all user accounts requires administrator privileges.


          It is also possible to add the keys instead of HKEY_LOCAL_MACHINE\Software\Classes to HKEY_CURRENT_USER\Software\Classes. That does not require administrator privileges for registration and adds the special Run As command for the current user account only.

          Execution of regedit.exe requires always administrator privileges even when importing data only to HKCU. Therefore the registration in HKCU should be better than with command REG which does not require administrator privileges on adding a key to HKCU. In this case command REG must be executed twice in a command prompt window.

          First command to execute is:

          REG ADD HKCU\Software\Classes\*shell\runas /ve /t REG_SZ /d "UltraEdit as Admin"

          The second command to execute is:

          REG ADD HKCU\Software\Classes\*shell\runas\command /ve /t REG_SZ /d "\"Path to UltraEdit program files directory\uedit32.exe\" /fni \"%1\""

          Backslashes in the path must not be escaped with an additional backslash as required in the *.reg file. Just every double quote inside the data string must be escaped with a backslash as shown above. On both commands /f could be appended as an additional parameter to force overwriting an existing value without asking the user for confirmation.

          With the command

          REG DELETE HKCU\Software\Classes\*shell\runas /f

          or

          REG DELETE HKCU\Software\Classes\*shell /f

          the entire key runas respectively the key shell can be removed without user confirmation.


          The direct registration of such a runas key for all files makes it impossible to register 2 applications using this method.

          4
          NewbieNewbie
          4

            Nov 09, 2015#5

            I think instead of messing with the OS, better if UE can support Save As elevation to Administrator.
            Npp has a plugin that does just that, so I guess we can ask the UE authors to add this feature.