Repository navigation
fs: add support for flag --no-console on windows to hide the console … - #4953
Conversation
ncw
left a comment
There was a problem hiding this comment.
This is a nice feature :-)
See inline for a could of comments.
I thought you had to do this with linker flags...
PS: Should it be called --no-console or --hide-console, or something else? Syncthing used no-console, and rclone already have some --no-... flags so I kept that.
Happy to go with prior art of syncthing
PS 2: It would be nice to include this in a doc page for the typical use case of auto-starting rclone for mount etc. The following from Syncthing is really detailed and well written and could serve as an inspiration: https://docs.syncthing.net/users/autostart.html
Yes autostart could be a new page, or maybe a section in the install.md - nice idea. We could put systemd for mount and cron for syncing in there.
There was a problem hiding this comment.
I try (I don't always succeed!) to make the internal names HideConsole agree with the flag names --no-console - so let's pick one or the other! Note that the internal names show in the rc.
There was a problem hiding this comment.
Makes sense. Function is called HideConsole, and flag is called no-console, so internal name matched the function name instead of the flag name. Switched that. Could have renamed the function also to NoConsole but think it is more correct to call it HideConsole since that is what it does.
|
Force-pushed an update according to your comments. Merge if you think its ok now, if not just let me know and I will be happy to do another iteration.
It will be a nice addition, and easier for new users, ref various forum threads on the subject. But its not at all perfect, it annoys me that the console window flashes on startup, but seemed like Syncthing had a couple of iterations on it without finding a better method, and I did not want to invest much more time myself.
I wanted to debug this issue related to mount, but since build failed I had to find something else to do that I could build without |
|
This looks great now - thank you! I will merge it now. Note that here: https://stackoverflow.com/a/23250506/164234 shows how to link the executable so the console window never appears. I don't think we want to do this but I thought you might like to see it if you haven't already. |
What is broken? I think you posted on the forum about this but my memory is failing me here ;-) |
|
Yes, it was the mingw gcc error "export ordinal too large". Solved by adding "-buildmode exe". Thank you for that tip! :) |
What is the purpose of this change?
Add option to hide rclone's console window, with a new flag
--no-console. Mostly relevant in combination with remote control, mount, web gui etc commands, but also long running sync operations etc, and especially when starting rclone automatically from task scheduler or windows service (nssm).The implementation is based on Syncthing's:
syncthing/syncthing@80dca96
Note: When starting
rclonewith--no-consolefrom "run" dialog, desktop shortcut etc, the console window "flashes" briefly on startup, before it gets set to hidden. If you start upcmd.exeand then executerclonewith--no-consolefrom there, it actually hides the existing cmd.exe window, and when rclone process exits the cmd process is left running hidden. This can perhaps be a bit surprising for users, but I do not know a way around it (this is how Syncthing does it as well).PS: Should it be called --no-console or --hide-console, or something else? Syncthing used no-console, and rclone already have some --no-... flags so I kept that.
PS 2: It would be nice to include this in a doc page for the typical use case of auto-starting rclone for mount etc. The following from Syncthing is really detailed and well written and could serve as an inspiration: https://docs.syncthing.net/users/autostart.html
Was the change discussed in an issue or in the forum before?
The actual option has not been discussed, but tips and workarounds on how to hide the console window has been discussed numerous times.
https://forum.rclone.org/t/how-to-mount-a-personal-jottacloud-as-a-drive-on-win10/21601/37
https://forum.rclone.org/t/autostart-mount-on-windows-without-cmd-popping-up/20896
Checklist
I have added tests for all changes in this PR if appropriate.I have added documentation for the changes if appropriate.