Skip to content

[HowTo] Schedule runs on Windows

Vladimir Budylnikov edited this page Jul 14, 2025 · 10 revisions

πŸ•ΉοΈ How to Schedule Free Games Claimer Script on Windows (Batch Version)

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.


🧰 1. Install Requirements

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-interactivity

Or install manually:


πŸ“ 2. Select Working Directory

Choose where the project and data will live. This example uses:

%userprofile%\Documents\Git\FGC

🧱 3. Create Folders and Clone Repository

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.git

πŸ“¦ 4. Create GLOBAL_VARIABLES.env

Inside FGC folder, create a file named GLOBAL_VARIABLES.env. It must contain at least this line:

USERS_LIST=User1 User2

Optional additional global settings:

SHOW=1
TIMEOUT=360
GIT_BRANCH=main

πŸ‘€ 5. Create Per-User Environment Files

You 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=AnotherPasswordHere

🧾 6. Create fgc.bat Script

Create 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

πŸ—“οΈ 7. Automate with Task Scheduler

  1. Press πŸͺŸ Start, search Task Scheduler.

  2. Click Create Basic Task...

  3. 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
      
  4. Click Finish, then right-click β†’ Run to test it.