Skip to main content

Windows Installer Developer Guide

This guide explains how to build:

  • server.exe and encrypt.exe (backend binaries)
  • build_config.exe (config packer utility)
  • Inventory_Installer.exe (UI installer)
  • backend_Installer.exe (full bootstrap installer)

1. Prerequisites​

Install these on your Windows build machine:

  • Flutter SDK (with Windows desktop support)
  • Node.js 18+
  • npm
  • Inno Setup 6
  • Visual C++ Redistributable package file (vc_redist.x64.exe)
  • PostgreSQL offline installer file (postgresql-18.3-2-windows-x64.exe) for full backend installer

Official links:

2. Build Backend EXE Files​

From project root:

cd backend
npm install
npm install --save-dev pkg
npx pkg .\server.js --targets node18-win-x64 --output .\server.exe
npx pkg .\build_config.js --targets node18-win-x64 --output .\build_config.exe
npx pkg .\encrypt.js --targets node18-win-x64 --output .\encrypt.exe

Expected output in backend/:

  • server.exe
  • build_config.exe
  • encrypt.exe

2.1 build_config.exe Guide​

Purpose:

  • Creates sysConfig.enc from values inside backend\build_config.js.

How to use:

  1. Edit rawConfig in backend\build_config.js with real values.
  2. Build executable:
cd backend
npx pkg .\build_config.js --targets node18-win-x64 --output .\build_config.exe
  1. Run:
.\build_config.exe

Expected output:

  • backend\sysConfig.enc

Notes:

  • Do not ship build_config.js with real secrets.
  • Ship only sysConfig.enc in installer payload.

2.2 encrypt.exe Guide​

Purpose:

  • Encrypts config.json into config.enc using logic from backend\encrypt.js.

How to use:

  1. Ensure backend\config.json exists.
  2. Build executable:
cd backend
npx pkg .\encrypt.js --targets node18-win-x64 --output .\encrypt.exe
  1. Run:
.\encrypt.exe

Expected output:

  • backend\config.enc

Notes:

  • In your current installer flow, backend.iss runs encrypt.exe during install.
  • config.json is temporary and should be deleted after encryption.

3. Build Flutter Windows Release​

From project root:

flutter clean
flutter pub get
flutter build windows --release

Expected UI build output folder:

  • build\windows\x64\runner\Release\

4. Prepare Installer Input Files​

Make sure these files are present before compiling installer scripts:

  • build\windows\x64\runner\Release\*
  • backend\server.exe
  • backend\build_config.exe (optional utility, not required at runtime)
  • backend\encrypt.exe
  • backend\license.key
  • backend\sysConfig.enc (generated by your config flow)
  • backend\run_hidden.vbs
  • installer\app_icon.ico
  • installer\vc_redist.x64.exe
  • installer\postgresql-18.3-2-windows-x64.exe

5. Update .iss Source Paths​

Current scripts use hard-coded paths like D:\inventory\.... Before building, open these files and replace Source: paths with your machine paths:

  • installer\inventory_fsetup.iss
  • installer\backend.iss

Recommended: keep one stable build root (example: D:\inventory) to avoid frequent edits.

6. Compile Inventory Installer (UI + Optional Backend)​

Compile:

"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "installer\inventory_fsetup.iss"

Expected output:

  • Inventory_Installer.exe (as defined by OutputBaseFilename)

7. Compile Backend Bootstrap Installer​

This installer runs prerequisites and then runs Inventory_Installer.exe.

Compile:

"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "installer\backend.iss"

Expected output:

  • backend_Installer.exe (as defined by OutputBaseFilename)

8. What Each Installer Does​

inventory_fsetup.iss:

  • Installs UI for Server and Client modes
  • Installs backend files only for Server mode
  • Creates desktop/start-menu shortcuts
  • Adds firewall rule for port 3000
  • Registers backend auto-start (run_hidden.vbs)

backend.iss:

  • Installs VC++ runtime and PostgreSQL (if missing)
  • Creates database/user with secure random credentials
  • Generates encrypted config at install time
  • Runs Inventory_Installer.exe silently

9. Validation Checklist​

After installation on a clean Windows machine:

  1. App launches from desktop shortcut.
  2. server.exe is running (Server mode).
  3. API responds on http://127.0.0.1:3000/health.
  4. Windows Firewall rule for port 3000 exists.
  5. Reboot test confirms backend auto-start.
  6. Uninstall removes app files and cleanup logic works.

10. Troubleshooting​

  • ISCC.exe not found:
    • Check Inno Setup install path or add ISCC.exe to PATH.
  • Source file not found during compile:
    • One or more Source: paths in .iss still point to old location.
  • App opens but backend fails:
    • Verify server.exe, license.key, sysConfig.enc, run_hidden.vbs are in install directory.
  • PostgreSQL install problems:
    • Confirm installer file name matches backend.iss exactly.

11. Google Script Setup Guide​

Use this when configuring:

const rawConfig = {
sheetId: "1hxxxxxxxxxxxxxxxxxxxxxxThE",
scriptUrl: "https://script.google.com/macros/s/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/exec",
emailId: "hxx@domain.com",
emailPass: "xxxx xxxx xxxx",
rootFolderId: "1Ipxxxxxxxxxxxxxxxxxxxxxxx0Ke"
};

11.1 Create Google Sheet​

  1. Create a Google Sheet and copy its ID (sheetId) from URL.
  2. Create sheet tabs:
    • Clients
    • Update
  3. Clients is used for license/client records.
  4. Update is used by app update check (latest_version, download URL, changelog, date).

11.2 Create Google Drive Root Folder​

  1. Create a Drive folder that will hold all client folders/backups.
  2. Copy that folder ID as rootFolderId.

11.3 Deploy Apps Script Web App​

  1. Open script.google.com.
  2. New project -> paste script from installer\scriptgoogle.txt.
  3. Save project.
  4. Deploy -> New deployment -> Web app.
  5. Execute as: your account.
  6. Who has access: anyone with link (or your required policy).
  7. Deploy and copy Web App URL to scriptUrl.

11.4 Set rawConfig and Generate sysConfig.enc​

  1. Open backend\build_config.js.
  2. Replace rawConfig values with real sheetId, scriptUrl, emailId, emailPass, rootFolderId.
  3. Build and run:
cd backend
npx pkg .\build_config.js --targets node18-win-x64 --output .\build_config.exe
.\build_config.exe
  1. Output file:
    • backend\sysConfig.enc

sysConfig.enc is the file used at runtime by backend cloud sync features.

11.5 Quick Connectivity Test​

After install, trigger any feature that syncs/checks cloud:

  • update check
  • client upsert
  • backup upload

If scriptUrl/IDs are wrong, backend logs will show cloud communication errors.

12. license.key Guide​

Purpose:

  • Enables/validates application licensing in backend startup and API flows.

File handling:

  1. Keep license.key in backend\license.key before packaging.
  2. inventory_fsetup.iss includes it in server component install.
  3. At runtime it must exist in install directory beside server.exe.

Packaging reference:

  • installer\inventory_fsetup.iss includes:
    • Source: "...\backend\license.key"; DestDir: "{app}"

13. run_hidden.vbs Guide​

Purpose:

  • Launches server.exe silently (no console window), using its own folder as working directory.

Behavior:

  • Resolves script folder path.
  • Sets current directory to that folder.
  • Runs server.exe hidden.

File handling:

  1. Keep backend\run_hidden.vbs with backend payload.
  2. inventory_fsetup.iss copies it to {app} for Server install type.
  3. It is used for:
    • startup registry entry
    • scheduled task INVINS_Server
    • post-install backend start

Google Script and config:

  • Google Apps Script source:
    • installer\scriptgoogle.txt
  • Raw secure cloud config template:
    • backend\build_config.js (rawConfig)
  • Runtime decrypt for sysConfig.enc:
    • backend\utils\configManager.js

Backend cloud integration:

  • Main Google Script caller:
    • backend\modules\driveService.js
  • Client sync trigger logic:
    • backend\modules\sheetService.js
  • Update-check endpoint (uses check_update):
    • backend\controllers\public\updateController.js
  • Config upload/download to Drive:
    • backend\modules\updownconfig.js

Installer and startup:

  • Server/client installer:
    • installer\inventory_fsetup.iss
  • Bootstrap installer:
    • installer\backend.iss
  • Silent launcher script:
    • backend\run_hidden.vbs