Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I switch to admin user in emacs on windows?

Tags:

emacs

uac

Perhaps I should be asking this on Superuser, but there are many other Emacs questions here so I thought I would try my luck.

I use GNU Emacs 23.2.1 on Windows 7 with User Access Control enabled.

In Emacs, I would like to make changes to some admin files (eg. hosts file). However, on attempting to save the file I get a warning that I do not have permission to write to the file.

Is there a way to get Emacs to escalate to the admin user for editing these files ?

like image 811
Martin Avatar asked Dec 17 '10 11:12

Martin


1 Answers

You could always just admit defeat and run the emacs session with elevated privileges. There's a bunch of ways to do this, and this page lists them, including automatically running stuff as administrator.

This is probably not quite what you want. Otherwise you might create a script that gets a filename as it's first argument, and then just bind that program to a shortcut or something, like admin-save. If you give that administrator rights, and then call the file with the buffer name as it's first argument and it's destination as it's second, you should be good.

The script could be a simple BATfile, something ala (I'm not on a Windows box so I can't test it for myself)

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

But that's a rather clunky solution though.

How to elevate an already running application I do not know.

like image 73
Haakon Løtveit Avatar answered Sep 18 '22 11:09

Haakon Løtveit