Keeping Syncthing Running: Windows XP, Vista, 7, 8

(Vsandre) #1

I will describe the way to start syncthing in the background via the Windows Task Scheduler System SCHTASKS. Syncthing will then start with the System and run with the given User-Rights.

Creating the task: Run this CMD line in the syncthing directory or replace %CD% with right path. To run syncthing without login you have to set your USERNAME and PASSWORD.

SCHTASKS /Create /TN Syncthing /TR %CD%\syncthing.exe /SC ONSTART /RU MyDomain\MyLogin /RP MyPassword

Start Synchting task the first time:    SCHTASKS /Run /TN Syncthing

Stop Syncthing task, for example to update syncthing:     SCHTASKS /End /TN Syncthing

1 Like

(Jpjp) #2

Great! Do you have write access on this page to create a topic? https://forum.syncthing.net/category/documentation

0 Likes

(Vsandre) #3

I found the category “how to”.

0 Likes

(Kardianos) #4

The other way to do this is to use the OS provided service method, as may be provided by: bitbucket.org/kardianos/service or other libraries.

0 Likes

(Roxo Doxer) #5

Some assistance would be greatly appreciated.

When I create the task it says it was successfully created and when I try to run it, it also says it worked, but then when I go to 127.0.0.1:8080 nothing shows up, and I can’t find the task using the task manager either.

0 Likes

(Neon Horizon) #6

I had this problem as well, it turned out for me it was because my path had a space in it because I put the executable in Program Files so it thought the executable was called C:\Program and the options were Files etc. I fixed it by using the GUI:

  1. Open the task scheduler GUI, (I did this by right clicking on computer in the start menu and selecting manage but you can also do it by searching for task scheduler and opening it)
  2. Go to the Task Scheduler Library (its like a tree view, you will find it if you look)
  3. Right click and select properties on the syncthing task you created
  4. Select the actions tab and select and click edit on the “Start a program” line
  5. Fix it, click OK, OK, OK etc…

Hopefully this helps :smile:

PS: No wonder vsandre explained how to set it up on the command line, theres a lot of clicking about!

0 Likes

(Vsandre) #7

Of course :wink:

If you want to do this via comand line you have to use quotation marks.

/TR "path to files/syncthing.exe"
0 Likes

(Neon Horizon) #8

Yeah I thought I did that but I can’t have done?

0 Likes

(Arne Ko) #9

Thanks for sharing this. I followed your instructions, not having much experience with Win tasks. It seemed to crash syncthing though, so I went back to starting it manually. However, looking at the Task Scheduler today, I noticed, that your command will stop syncthing when the computer is on battery! That’s nice, but it might explain why I couldn’t get it to run reliably. This should be mentioned in your howto.

Also, since there doesn’t seem to be a way to paste text in the cmd window, it’d probably improve this howto if you mentioned, that this had to be done with administrator rights. I forgot about that, and had to type in your lengthy command (that I obviously did not understand completely) twice :stuck_out_tongue:

Just my 2 cents Thanks!

0 Likes

(Artem Baguinski) #10

there is a typo here (Synchting)

0 Likes

(Vsandre) #11

Thanks. Corrected in the example. BTW Works great in combination with the new windows update of syncthing.

0 Likes

(Jakob Borg) #12

Thanks! (I made the post wiki editable now; unfortunately that can’t be set as default per category…)

0 Likes

#13

I had some problems with this and found what I think is a bug in Windows (7/Pro/64). Even if you put your path and filename in quotes ("), the task scheduler will treat the part up to the first space (C:\Program) as the executable to be run, and the rest (Files…) as parameters. I found that it is possible to get round this by enclosing the full path/filename in double quotes and then additionally in single quotes.

0 Likes

(Frioux) #14

You guys might check out nssm, it is a way to run any program on a service on windows, and it will restart it if it dies, etc. I have syncthing running on my wife’s computer with this. I’ll post how I got it to work later if someone else doesn’t beat me to it.

0 Likes

(Frioux) #15

Er, woops, someone already did! Start syncthing in background without shell window / as a Windows service

0 Likes

(uok) #16

I you want to run Syncthing on startup and hide the command line window completely (also no tray icon) you can edit the task in the task scheduler GUI (as @NeonHorizon described above) and check “hidden” in the properties. Please note that this only starts Syncthing at bootup but it is not run as a service (e.g. if you kill the task it will not restart). As an alternative you can use SyncTray (https://github.com/iss0/SyncthingTray) which creates a tray icon with a simple user interface for start/stop

0 Likes

(Sean) #17

Using NSSM worked better for me, using a Windows 8.1 computer. The Windows Task Scheduler method above didn’t work, but I follows the post it Start syncthing in background without shell window / as a Windows service and it did.

0 Likes