Skip to content
20 changes: 20 additions & 0 deletions users/autostart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,26 @@ by a sysadmin who knows enough to understand the security implications.
#. Start the service via ``sc start syncthing`` in the Command Prompt.
#. Connect to the Syncthing UI, enable HTTPS, and set a secure username and password.

For Advanced Users
^^^^^^^^^^^^^^^^^^

It's possible to run Windows Task Scheduler CLI API with a command such as
``schtasks /create /sc ONLOGON /tn Syncthing /tr "<program-path> [--no-console --no-browser]"``.
The operation requires elevated privileges. Preventing the pop-up console that hides after
some delay is possible wrapping the executable with a ``PowerShell`` script.

``script.ps1``::

Start-Process "<path to syncthing>.exe" -WindowStyle Hidden
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your schtasks example includes --no-console --no-browser but your
Powershell example doesn't. Perhaps it should, so the two examples mirror each other?

Also, isn't -File required? So: powershell -File <path to script>.ps1 ?

Copy link
Author

@rafaeloledo rafaeloledo Aug 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows Terminal and Default Console:
In modern Windows versions, particularly with Windows Terminal set as the default console application, the --no-console flag might not completely hide the console window. It might still appear and then minimize, or the flag might be ignored entirely.

https://forum.syncthing.net/t/win-10-and-11-updates-breaks-no-console/19142

I was trying the --no-console flag that only exists in the Windows version of the syncthing and faced some issues related.

Switching to the mentioned legacy mode may be discouraged, since Windows Terminal is being a default on all new installations.

Wrapping with a ps1 script works even on wt.exe pop-ups.

-File/-FilePath is not mandatory.

Start-Process
    [-FilePath] <string>
    [[-ArgumentList] <string[]>]
    [-WorkingDirectory <string>]
    [-PassThru]
    [-Verb <string>]
    [-WindowStyle <ProcessWindowStyle>]
    [-Wait]
    [-Environment <hashtable>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

https://learn.microsoft.com/pt-br/powershell/module/microsoft.powershell.management/start-process?view=powershell-7.5
https://learn.microsoft.com/pt-br/powershell/module/microsoft.powershell.management/start-process?view=powershell-5.1

If you give the path as a first argument, it assumes that is the -FilePath flag as you can see above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might also try conhost.exe --headless ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might also try conhost.exe --headless ...

I've not tested it. Feel free to contribute and do it. I don't have Windows installation on my PC right now...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-File/-FilePath is not mandatory.

I wasn't referring to Start-Process but to the powershell command itself:

powershell -File "<path to script>.ps1"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still works without -File, but I'm not sure if it implicitly defaults to -File script.ps1 or rather -Command script.ps1 🙃.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not on my system:

If you want to skip the -File option, you need to use:
powershell .\script.ps1.

Better to just tell our readers to use the option, as <path to script> is vague, imho.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still works without -File, but I'm not sure if it implicitly defaults to -File script.ps1 or rather -Command script.ps1 🙃.

Unfortunately @rasa example is what happening in my system too.

image

So, the -File flag is mandatory in this case.

Copy link
Author

@rafaeloledo rafaeloledo Aug 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-File/-FilePath is not mandatory.

I wasn't referring to Start-Process but to the powershell command itself:

powershell -File "<path to script>.ps1"

image

I can only find docs offline about powershell.exe. But, as you can see, even if it is treated as optional, you'll need to use the dot operator to resolve file paths. Using -File directly can be more user friendly considering that the operator is less known by non programmers.


Then run as admin::

schtasks /create /sc ONLOGON /tn Syncthing /tr "powershell <path to script>.ps1"


For more information, please read official docs for Command Line Interface API:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks

macOS
-----

Expand Down