micro
micro copied to clipboard
Run with internal flag when saving with sudo on Windows
An internal flag is used, because there is no program available by default on Windows that can be used in place of the dd command.
I was running micro -encoding shift_jis C:\test.txt then saving with ファイル内容 as content when testing. There should be no text corruption when running the command again to check how file is written.
The methods below were considered:
-
ShellExecute: data cannot be written to the standard input of the process - PowerShell: script with around 10 lines has to be used
All programs below except runas worked when used as sucmd:
-
runas- available by default in Windows 2000 and newer but standard input was read as password when testing
- user to run command as needs to be specified
- command and arguments are specified in one string
-
Sudo for Windows
- source code is on GitHub but there are only official builds on Windows 11
-
gsudo
- seems to be known in recent years when searching programs like sudo on Windows
- wrapper with
sudoname can be enabled using installer - saving only worked in TokenSwitch mode (current default)
- .NET objects used in the code of other modes probably handle data in standard input as text
Closes #3541