How to switch to admin user in emacs on windows?

Maybe I should ask Superuser about this, but there are a lot of other Emacs questions here, so I thought I'd try my luck.

I am using GNU Emacs 23.2.1 on Windows 7 with user access control enabled.

In Emacs, I would like to make changes to some administrators files (for example, the hosts file). However, when I try to save the file, I get a warning that I do not have permission to write to the file.

Is there a way to force Emacs to escalate to an administrator user to edit these files?

+7
source share
1 answer

You can always simply admit defeat and start an elevated privileged emacs session. There are many ways to do this, and this page lists them, including automatically launching the file as an administrator.

This is probably not exactly what you want. Otherwise, you can create a script that takes the file name as the first argument, and then simply binds this program to a shortcut or something like admin-save. If you give administrator privileges and then call the file with the buffer name as the first argument, and its purpose will be the second, you should be good.

the script may be a simple BAT file, something ala (I'm not in a windows window, so I can not check it for myself)

:: Administrator-copy.bat copies a file with adminstrator privileges. :: Remember to give it administrator privileges! : START COPY %1 %2 : END 

But this is a rather clumsy decision.

How to raise an already running application, I do not know.

+3
source

All Articles