Hi Boris!
On So, 23 Dez 2012, Boris Danilov wrote:
> >On Wed, December 19, 2012 15:33, Ben Fritz wrote:
> >> On Wednesday, December 19, 2012 3:52:01 AM UTC-6, Boris Danilov wrote:
> >>> Hello! Vim is great editor, but I have some trouble when working under
> >>> normal user account and editing files in places with restricted access
> (like
> >>> Program Files and etc.). Is there a way to make Vim elevate access
> >>> rights when saving a file? I want Vim to display me the UAC dialogue
> where
> >>> I must confirm the operation instead of giving me a message that write
> >>> failed? Is there anything I can do without running Vim under
> administrator
> >>> privilegies or disabling UAC?
> >>>
> >>
> >> I'm pretty sure you're stuck launching Vim with admin privileges.
> >>
> >> You might be able to hack something together with one or more of these
> >> search results:
> >>
> >> https://www.google.com/search?q=windows+sudo+command
> >>
> >> But doing that you'd need to bypass Vim's normal write mechanisms,
> >> probably with a BufWriteCmd autocmd. I think you're better off just
> >> launching Vim with admin rights, as people basically do on Linux when
> >> editing system files (using "sudo" to give root access).
> >
> >Also, please see this comment in my plugin SudoEdit:
> >https://github.com/chrisbra/SudoEdit.vim/blob/master/doc/SudoEdit.txt#L143
> >
> >I would be interested in Windows users experiences.
> >
> >regards,
> >Christian
>
> Thanks for reposting this to the mailing list. SudoEdit is exactly what I
> was looking for. Too bad it can't give me fancy UAC dialogue, but I don't
> care. However, I've encountered a problem using SudoEdit. First it has a
> misprint where the varialbe s:writable_file is being initialized in
> function Init (where it is written as s:writEable_file there). Then I had
> to use the following g:sudoAuthArg="/noprofile /user:Grin" in my vimrc,
> because my Administrator account is renamed.
>
> Then I'm getting the following output when I'm trying to save file test.vim
> with :SudoWrite test2.vim.
>
> >>>>>
> C:\Windows\system32\cmd.exe /c C:\Users\Boris\vimfiles\autoload\sudo.cmd
> "test.v
> im" C:\Users\Boris\AppData\Local\Temp\VIB9AAD.tmp write runas /noprofile
> /user:Grin
>
> C:\Program Files (x86)\Vim\vim73\keymap>SETLOCAL ENABLEEXTENSIONS
>
> C:\Program Files (x86)\Vim\vim73\keymap>set myfile="test.vim"
>
> C:\Program Files (x86)\Vim\vim73\keymap>set
> newcontent=C:\Users\Boris\AppData\Lo
> cal\Temp\VIB9AAD.tmp
>
> C:\Program Files (x86)\Vim\vim73\keymap>set mode=write
>
> C:\Program Files (x86)\Vim\vim73\keymap>set sudo=runas
>
> C:\Program Files (x86)\Vim\vim73\keymap>shift
>
> C:\Program Files (x86)\Vim\vim73\keymap>shift
>
> C:\Program Files (x86)\Vim\vim73\keymap>shift
>
> C:\Program Files (x86)\Vim\vim73\keymap>shift
>
> C:\Program Files (x86)\Vim\vim73\keymap>set params=/noprofile
>
> C:\Program Files (x86)\Vim\vim73\keymap>shift
>
> C:\Program Files (x86)\Vim\vim73\keymap>if [/user:Grin] == [] goto afterloop
>
> C:\Program Files (x86)\Vim\vim73\keymap>set params=/noprofile /user:Grin
>
> C:\Program Files (x86)\Vim\vim73\keymap>goto loop
>
> C:\Program Files (x86)\Vim\vim73\keymap>shift
>
> C:\Program Files (x86)\Vim\vim73\keymap>if [] == [] goto afterloop
>
> C:\Program Files (x86)\Vim\vim73\keymap>if write == 'write' (runas
> /noprofile /u
> ser:Grin "cmd.exe /k type C:\Users\Boris\AppData\Local\Temp\VIB9AAD.tmp
> >"test.
> vim"" ) else (runas /noprofile /user:Grin "cmd.exe /c type "test.vim"
> >C:\User
> s\Boris\AppData\Local\Temp\VIB9AAD.tmp" )
> Enter the password for Grin:
> Attempting to start cmd.exe /c type test.vim
> >C:\Users\Boris\AppData\Local\Temp\
> VIB9AAD.tmp as user "COMPUTERNAME\Grin" ...
> Hit any key to close this window...
> <<<<<
>
> It doesn't write the file and gives me an error message that file wasn't
> written in Vim.
I have only seldom access to windows, but this command should work,
shouldn't it? Can you verify, that either of the commands:
%sudo% %params% "cmd.exe /k type %newcontent% >%myfile%"
and
%sudo% %params% "cmd.exe /c type %myfile% >%newcontent%"
works? (Please replace %sudo% by runas, %params" by you parameters for
runas and %myfile% and %newcontent% by the name of the file as given in
the commandline?
BTW: It might be better to solve this issue off list.
regards,
Christian
--
Zur Wahrheit führen rauhe, dunkle Bahnen,
Erst später erfüllt sich, was wir früh schon ahnen.
-- Friedrich von Bodenstedt (Mirza Schaffy)
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Sunday, December 23, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment