-
-
Notifications
You must be signed in to change notification settings - Fork 250
[HowTo] Schedule runs on Windows
This guide helps you install and configure the free-games-claimer project using a robust fgc.bat batch script with support for multiple users, .env files, Playwright setup, and Windows Task Scheduler.
Install the latest versions of Git and Node.js.
β Preferred method: Microsoft WinGet
winget install "git.git" --accept-source-agreements --silent --disable-interactivity
winget install "Node.js" --accept-source-agreements --silent --disable-interactivityOr install manually:
Choose where the project and data will live. This example uses:
%userprofile%\Documents\Git\FGC
Open CMD (search CMD in πͺ Start Menu) and run:
mkdir %userprofile%\Documents\Git
mkdir %userprofile%\Documents\Git\FGC
cd %userprofile%\Documents\Git\FGC
git clone https://github.com/vogler/free-games-claimer.gitInside FGC folder, create a file named GLOBAL_VARIABLES.env. It must contain at least this line:
USERS_LIST=User1 User2Optional additional global settings:
SHOW=1
TIMEOUT=360
GIT_BRANCH=mainYou can skip this step, if you log in manually.
For each user in USERS_LIST, create a corresponding file named User1.env, User2.env, etc.
Example User1.env:
EG_EMAIL=user1@example.com
EG_PASSWORD=YourPasswordHere
EG_OTPKEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
GOG_EMAIL=user1@outlook.com
GOG_PASSWORD=AnotherPasswordHereCreate the file %userprofile%\Documents\Git\FGC\fgc.bat with the following content:
π‘ This is the final, production-ready version:
@echo off
echo πΎ This is a helper batch script for Windows for running Vogler's free-games-claimer
echo πΎ For details see: https://github.com/vogler/free-games-claimer/wiki/%5BHowTo%5D-Schedule-runs-on-Windows
echo πΎ Script written by GitHub user nett00n: https://github.com/nett00n
:: -----------------------------------------------------------------------------
:: Set defaults BEFORE attempting to load GLOBAL_VARIABLES.env
set SHOW=1
set TIMEOUT=360
set GIT_BRANCH=main
echo π· Default Variables:
echo β» SHOW=%SHOW% (0 = silent, 1 = show browser)
echo β» TIMEOUT=%TIMEOUT% seconds between users
echo β» GIT_BRANCH=%GIT_BRANCH% repository branch
:: -----------------------------------------------------------------------------
:: Load GLOBAL_VARIABLES.env (REQUIRED)
if not exist "GLOBAL_VARIABLES.env" (
echo π₯ GLOBAL_VARIABLES.env not found! This file is required. Exiting...
echo.
echo βΉοΈ Please create a file named GLOBAL_VARIABLES.env in this directory with at least the following:
echo.
echo USERS_LIST=yourUsername1 yourUsername2
echo.
echo βΉοΈ Also you can set there following variables:
echo SHOW=1
echo TIMEOUT=360
echo GIT_BRANCH=main
echo.
echo π‘ Refer to the documentation:
echo https://github.com/vogler/free-games-claimer/wiki/%5BHowTo%5D-Schedule-runs-on-Windows
echo.
TIMEOUT 60
exit /b 1
)
echo π· Loading GLOBAL_VARIABLES.env...
for /f "usebackq tokens=1,* delims==" %%A in ("GLOBAL_VARIABLES.env") do (
echo %%A | findstr "^[#]" >nul
if errorlevel 1 (
set "%%A=%%B"
echo βοΈ Loaded: %%A=%%B
)
)
:: -----------------------------------------------------------------------------
:: Verify USERS_LIST is set and not empty
if not defined USERS_LIST (
echo π₯ USERS_LIST is not defined or empty in GLOBAL_VARIABLES.env! Exiting...
echo.
echo βΉοΈ Make sure your GLOBAL_VARIABLES.env file includes a line like:
echo USERS_LIST=yourUsername1 yourUsername2
echo.
echo π‘ Refer to the example in the docs:
echo https://github.com/vogler/free-games-claimer/wiki/%5BHowTo%5D-Schedule-runs-on-Windows
echo.
exit /b 1
)
echo β» USERS_LIST = [%USERS_LIST%]
:: -----------------------------------------------------------------------------
:: Check for required tools
echo π· Checking if everything is installed...
echo β» Checking Node.js...
where node >nul 2>nul
if errorlevel 1 (
echo π₯ Node.js is not installed. Exiting...
exit /b
)
echo β» Checking npx...
where npx >nul 2>nul
if errorlevel 1 (
echo π₯ npx is not installed. Exiting...
exit /b
)
echo β
All required tools are installed.
:: -----------------------------------------------------------------------------
:: Update Git repository
echo π· Updating Git repository...
cd /d "%userprofile%\Documents\Git\FGC\free-games-claimer" || (
echo π₯ Failed to switch to repo directory. Exiting...
exit /b
)
echo β» Reverting local changes...
git checkout .
echo β» Switching to branch: %GIT_BRANCH%...
git checkout %GIT_BRANCH%
echo β» Pulling latest changes...
git pull
:: -----------------------------------------------------------------------------
:: Install Node.js packages and Playwright
echo π· Installing Node.js dependencies...
cmd.exe /c npm install package.json
echo π· Installing Playwright...
cmd.exe /c npx playwright install
:: Move to base dir
cd /d "%userprofile%\Documents\Git\FGC" || (
echo π₯ Failed to switch to base directory. Exiting...
exit /b
)
:: -----------------------------------------------------------------------------
:: Loop through each user in USERS_LIST
for %%U in (%USERS_LIST%) do call :claim %%U
goto :eof
:: -----------------------------------------------------------------------------
:claim
setlocal
set USER=%1
echo.
echo π· Claiming games for user: %USER%
:: Load user-specific environment variables
if not exist "%USER%.env" (
echo π₯ %USER%.env not found. Skipping user: %USER%
goto :eof
)
echo β» Loading %USER%.env...
for /f "usebackq tokens=1,* delims==" %%A in ("%USER%.env") do (
echo %%A | findstr "^[#]" >nul
if errorlevel 1 (
set "%%A=%%B"
echo βοΈ Loaded: %%A=%%B
)
)
set "BROWSER_DIR=data/%USER%"
:: Check if Epic Games password is defined and not empty
if defined EG_PASSWORD (
if not "%EG_PASSWORD%"=="" (
echo π· Claiming Epic Games for %USER%...
cmd.exe /c node free-games-claimer/epic-games.js
) else (
echo π₯ EG_PASSWORD is empty for %USER%. Skipping Epic Games claim...
)
)
:: Check if GOG password is defined and not empty
if defined GOG_PASSWORD (
if not "%GOG_PASSWORD%"=="" (
echo π· Claiming GOG games for %USER%...
cmd.exe /c node free-games-claimer/gog.js
) else (
echo π₯ GOG_PASSWORD is empty for %USER%. Skipping GOG claim...
)
)
:: Check if Prime Gaming password is defined and not empty
if defined PG_PASSWORD (
if not "%PG_PASSWORD%"=="" (
echo π· Claiming Prime Gaming games for %USER%...
cmd.exe /c node free-games-claimer/prime-gaming.js
) else (
echo π₯ GOG_PASSWORD is empty for %USER%. Skipping GOG claim...
)
)
:: Optional: more services...
echo π· Waiting %TIMEOUT% seconds before next user...
timeout %TIMEOUT%
endlocal
goto :eof
-
Press
πͺ Start, search Task Scheduler. -
Click Create Basic Task...
-
Configure:
-
Name:
_Free-Games-Claimer -
Trigger:
Daily -
Start time: e.g.,
05:00:00 -
Action:
Start a Program -
Program/script:
%userprofile%\Documents\Git\FGC\fgc.bat
-
-
Click Finish, then right-click β Run to test it.