With modern Windows privileges schema (unlike in Windows XP) Emacs can't save edits to many of files placed in special directories (like "Program Files"). To allow saving of modification you should grand Administrator privileges to Emacs process.
Usual way to run program under Administrator privileges via menu Run as Administrator in Explorer or on desktop shortcut.
In order to run program as Administrator from batch file you have an option to use
utility. Unfortunately its option
/user:... takes account name and Administrator account name is
subject of localization so would be different depending on Windows local edition...
Cygwin comes with
cygstart utility and with
--action=runas option you can start program with
I maintain special script
e that is used to invoke
emacsclient with convenient behavior. For
example for Cygwin
emacs-w32 it makes special steps to hide console window.
I made decision to improve
e script so it would ask for Administrator privileges.
Because granting administrator privileges under Windows UAC mean that you will have a dialog with conformation in order to see this dialog only once I need to start only main Emacs server under this condition.
Because core part of
e script is just invocation of
-a ... option to
start Emacs server if it absent the only way to start Emacs by
cygstart is by supplying wrapper
-a option. Because I don't want to maintain and install additional script I told
emacsclient to invoke
e itself and guard from infinite invocation loop by setting
I start Emacs by
Enter. Windows doesn't understand sh-scripts, so it
e.bat. And if
emacsclient-w32 can't find running Emacs server it calls my
sh-script which start
for %%X in (emacsclient-w32.exe) do (set FOUND=%%~$PATH:X) if defined FOUND ( rem Cygwin Emacs-w32. set RUNEMACSARG=-a e set EMACSCLIENT=run --quote emacsclient-w32 set MAKECYGEMACSADMIN=yes ) %EMACSCLIENT% %RUNEMACSARG% %args% .
if [[ "$MAKECYGEMACSADMIN" = yes ]]; then unset MAKECYGEMACSADMIN exec cygstart --action=runas run emacs-w32 fi
Complete solution available at: http://hg.defun.work/utils/file/tip/emacs
Other scenarios of usage
e script as documented in man page aren't changed.