11

Is there a SublimeText plugin that reopens the current file as Administrator?

Notepad++ has a feature where, if you open a file and don't have the permissions to edit it, but try and save, it will inform you that you don't have the access, then give you the option of opening as an admin (if you have that permission), after which you can save.

I realise that there are work arounds, but this is a very convenient feature, and one I'd love to see in SublimeText.

To clarify, I don't want to be able to right click on the file in Windows Explorer, and pick "Open as." I'm aware of tools that let that happen; I'm specifically talking about once a file is opened as a non admin, and requires admin permissions to save.

3
  • 3
    Well tt least there is a feature-request ticket for that functionality: github.com/SublimeTextIssues/Core/issues/1200 Jun 25, 2017 at 1:03
  • 1
    Here is an alternative workaround. If you always work from files in a folder that requires admin rights. (e.g. c:\program files (x86) folders), you can right click on that folder. Go to Properties > Security > Edit > Add. And add yourself with Full Control permissions. You then should be able to edit any files from that folder without needing admin rights. (This of course, assumes that you already have admin rights.) Jan 24, 2018 at 16:27
  • Generally assuming a user trying to use UAC is an admin is a decent assumption. However, that means that randomly poorly written scripts and possible attacks can now much about the Microsoft part of your program files without prompting the user and without using a software exploit Jul 28, 2019 at 13:52

3 Answers 3

0

Go to gpedit and set these policies:

Windows Setings/Security Settings/Local Policies/Security Options

User Account Control: Admin Approval Mode for the Built-in Administrator account    Disabled
User Account Control: Allow UIAccess applications to prompt for elevation without using the secure desktop  Disabled
User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode    Elevate without prompting
User Account Control: Behavior of the elevation prompt for standard users   Prompt for credentials
User Account Control: Detect application installations and prompt for elevation Disabled
User Account Control: Only elevate executables that are signed and validated    Disabled
User Account Control: Only elevate UIAccess applications that are installed in secure locations Disabled
User Account Control: Run all administrators in Admin Approval Mode Disabled
User Account Control: Switch to the secure desktop when prompting for elevation Disabled
User Account Control: Virtualize file and registry write failures to per-user locations Enabled

Then set compatibility mode for the editor to always run as admin.

If you experience some problems you can relax "Admin Approval Mode for the Built-in Administrator account" to "Enabled" as long as you keep "Elevate without prompting".

You might even be able to skip compatibility setting for the app since these policies will give you automatic and silent elevation. Depends on the particular version of OS (LTSB version is very lenient, Home version is very totalitarian).

For some system folders you'll have to make sure that you are running x64 build. It's a different issue that looks like UAC to people but is not. Only Visual Studio knows how to sidestep that silently.

For "extra special" folders like Fonts all that is not going to help you. You'll have to jump more hops (including renaming C:\Windows\Fonts\desktop.ini) if you want to go in via UI but you'll go in just fine via admim cmd console.

So add your editor to path, keep one admin cmd always open and life is good.

2
  • This only applies to Windows ____ Pro due to gpedit.msc not being available for home. Jul 28, 2019 at 13:51
  • Search the net a bit :-) There are articles and scripts to "bring it back" :-)
    – ZXX
    Aug 5, 2019 at 14:39
0

If you're just talking about saving the file with Administrator privileges, look at Superlime.

Superlime requests root/admin rights if a file cannot be saved in SublimeText.

You can run Sublime Text as your normal user and save-with-privileges on just the files that need it.

Windows will give you a UAC elevation prompt and Linux will attempt to use your desktop environment's GUI prompt for sudo saving. (Macs automatically prompt without the Superlime package.)

-3

I just recently switched from npp to sublime and I found the easiest way to get around this is just disable UAC and set sublime to always run as admin.

Always open Sublime as admin Always open Sublime as admin

2
  • 1
    Never disable UAC. This is a security feature to inform users when programs might try to do something malicious. Jul 28, 2019 at 13:50
  • This is some seriously reckless disregard for security. Both steps are a very bad idea.
    – Vala
    Aug 21, 2023 at 12:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .