Reopen SublimeText as Administrator

notepadpluginssublime-text-3

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 go "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.

Best Answer

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.

Related Question