简体   繁体   English

如何在Windows上的emacs中切换到管理员用户?

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

Perhaps I should be asking this on Superuser, but there are many other Emacs questions here so I thought I would try my luck. 也许我应该在超级用户上问这个问题,但是这里还有很多其他的Emacs问题,所以我想我会试试运气。

I use GNU Emacs 23.2.1 on Windows 7 with User Access Control enabled. 我在Windows 7上使用GNU Emacs 23.2.1并启用了用户访问控制。

In Emacs, I would like to make changes to some admin files (eg. hosts file). 在Emacs中,我想对一些管理文件(例如hosts文件)进行更改。 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 ? 有没有办法让Emacs升级到管理员用户来编辑这些文件?

You could always just admit defeat and run the emacs session with elevated privileges. 您可以随时承认失败并使用提升的权限运行emacs会话。 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. 否则,您可能会创建一个脚本,该脚本获取文件名作为其第一个参数,然后将该程序绑定到快捷方式或其他内容,例如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) 脚本可能是一个简单的BAT文件,ala(我不在Windows机器上,所以我不能自己测试)

:: 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. 如何提升已经运行的应用程序我不知道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM