User Tools

Site Tools


guides:farming:chia_autostart_windows

Chia Autostart (Windows)

In this guide, we show you two methods for automatically restarting you Chia processess upon system reboot.

  • Method 1: Using a batchfile and the built-in Task Scheduler
  • Method 2: Using nssm.cc
  • Method 3: Using Windows Startup with PowerShell script

Method 1: Batchfile

This is a way to run the Chia node/farmer/harvester on a headless Windows machine. Anytime the machine reboots, this will start it all automatically. What you need is a batchfile in some location (eg C:\<Yourlocation>\BootChia.bat). You will also need to create a task through Task Scheduler.

Step 1 - Creating the Batchfile

Open Notepad and copy the following lines:

timeout /t 60 >NUL

START “Daemon” /b /normal %LOCALAPPDATA%\chia-blockchain\app-1.2.5\resources\app.asar.unpacked\daemon\chia.exe start farmer

Exit

and save in any location (eg C:\<Yourlocation>) as “BootChia.bat

The script has 3 components:

  1. A timeout: The timeout is to allow any initialization of virtual drives. If the log file (see below) shows errors then you may want to increase this to, say, 120 (seconds).
  2. A START function: Starts the Chia Daemon and the farmer
  3. Exit: closes the Batchfile

Note: Should you ever upgrade Chia, say to version 1.2.7 then the “app-1.2.5” part needs to be changed to “app-1.2.7”. You can cause plotting to start automatically as well, visit our discord server if you want to learn how.

Step 2 - Task Scheduler

  1. Click the Windows Start button and type in “Task Scheduler”
  2. Press “Create Task” (in Actions pane). A window appears
  3. Name: BootChia
  4. Description: Whatever
  5. Toggle “Run whether user is logged on or not”
  6. Tab Triggers
  7. Press “New”
  8. Select as Begin the task: At Startup
  9. Tab “Actions”
  10. Action → Start a program“
  11. Program/script → <Yourlocation>\BootChia.bat
  12. Add arguments (optional) → ”>\ChiaBoot.log 2>&1“ (Note both larger than signs, they are required)
  13. Start in (optional) → <Yourlocation>
  14. Press OK and again OK. You may need to provide your user password.

Voilà, next time your PC restarts, Chia will automatically start up.

Method 2 - using nssm.cc

nssm.cc (Non-Sucking Service Manager) allows you to start Chia as a service. Note that this requires to download (unmaintained) third-party software, so use at your own risk.

  1. Download at https://nssm.cc/download and unzip. You can save this in any location on your PC, but in this example we use the Downloads folder. You may replace that part of the path to your location if you safe it somewhere else.
  2. Change Directory to the folder in 1, in our case the Downloads folder: cd C:\Users\<username>\Downloads\nssm-2.24\win64
  3. type nssm.exe and hit enter
  4. Install chia.exe as a service: type nssm install Chia-service and hit enter
  5. A window will pop up. In the “Application” tab in the “Path” field fill in the location of the chia.exe file: %LOCALAPPDATA%\chia-blockchain\app-1.2.5\resources\app.asar.unpacked\daemon\chia
  6. Under “Startup directory”, us the the same, but without \chia %LOCALAPPDATA%\chia-blockchain\app-1.2.5\resources\app.asar.unpacked\daemon
  7. Under “Arguments” put start farmer
  8. proceed to the “Logon” tab. Select “this account” and provide your username and password :!: Again a disclaimer: Third-party software, use at your own risk.
  9. in the “Details” tab, select “automatic” in the dropdown.
  10. Click “Install Service” and you are done.

Go to the Windows Start button look for the “Services” app. Here you will find “Chia-service”. You can rightclick and press “Start” to test if it works (make sure you have no other instances of Chia running).

Now when your system reboots, chia.exe will automatically start. For more information, visit https://nssm.cc/usage and https://www.youtube.com/watch?v=96OtET8HmA0

Method 3: Using Windows Startup with PowerShell script

Step 1

  • Create a new file called Start_Farmer.cmd inside C:\Scripts\ folder

timeout /t 60 >NUL

powershell -windowstyle hidden C:\Scripts\Farmer.ps1 » C:\Scripts\startup.log

Step 2

  • Create a new file called Start_Farmer.ps1 inside C:\Scripts\ folder

$path = Get-item -Path $ENV:LOCALAPPDATA\chia-blockchain\app*\resources\app.asar.unpacked\daemon\chia.exe

&$path start farmer

Step 3

  • Browse to the %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup path
  • Create a shortcut to the C:\Scripts\Start_Farmer.cmd file
  • Now each time you restart and logon to the computer, the chia farmer will start automatically. After each Chia App version update, you do not need to update the script.

Disable Windows Auto-update

If you want to disable Windows automatic update, you can follow this guide: https://www.windowscentral.com/how-stop-updates-installing-automatically-windows-10.

Note that stalling updates for too long is not recommended (there's a reason for the updates).

guides/farming/chia_autostart_windows.txt · Last modified: 2021/09/27 15:29 by spacefarmer01