>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.

When I'm trying to save the file under the current filename with just
:SudoWrite I'm getting

>>>>>
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...
<<<<<

This time when I return to Vim the last row says the file test.vim was
written, but actually it is not, when I reopen it. I have no idea what is
going wrong there, but I've thought it might be because of write != 'write'
so I've removed quotes from 'write' in cmd file, but it doesn't look to
change anything except that I'm getting another cmd launched because of /k
flag. That way it doesn't write anything or give any errors with this
change either.

Regards,
Boris


On Wed, Dec 19, 2012 at 8:29 PM, Christian Brabandt <[email protected]>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
>
> --
> 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
>

-- 
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

Reply via email to