>>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
>
>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
Hello, Chris!
I've made a test directory without spaces on my C: drive to test this
and executed
commands
%sudo% %params% "cmd.exe /k type %newcontent% >%myfile%"
%sudo% %params% "cmd.exe /c type %myfile% >%newcontent%"
manually from the command line as you told. They both worked fine, here is the
listing:
>>>>
C:\test>runas /noprofile /user:Grin "cmd /k type c:\test\file.vim >C:\Users\Bor
is\AppData\Local\Temp\VIB6B75.tmp"
Enter the password for Grin:
Attempting to start cmd /k type c:\test\file.vim >C:\Users\Boris\AppData\Local\T
emp\VIB6B75.tmp as user "COMPUTERNAME\Grin" ...
C:\test>runas /noprofile /user:Grin "cmd /k type C:\Users\Boris\AppData\Local\T
emp\VIB6B75.tmp >c:\test\test3.vim"
Enter the password for Grin:
Attempting to start cmd /k type C:\Users\Boris\AppData\Local\Temp\VIB6B75.tmp >c
:\test\test3.vim as user "COMPUTERNAME\Grin" ...
<<<<
However I noticed that the new cmd starts in %WINDIR%\System32 and you
specify %myfile% as a relative name. That might be the problem. Also,
as I've said it looks like the value write of %mode% isn't equal to
'write' (with quotes) and this command doesn't write the initial file
as intended (I assume that was intended because by the time it prompts
me for password the .tmp file already contains the contents of the
buffer). Also, there might be problems with paths that contain spaces,
but let's make it work with normal directory names at first.
Regards,
Boris
--
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