From 31616440305e3fc25b42abb538ff9dcf48a63aff Mon Sep 17 00:00:00 2001 From: Giang Pham Date: Sat, 8 Nov 2025 11:59:36 +0700 Subject: [PATCH] [IMP] Installation script for Windows --- README.md | 33 +++--- install_script/create_shortcuts.ps1 | 62 +++++++++--- install_script/macos_installer.py | 1 - install_script/windows.bat | 151 +++++++++++++++++++++------- install_script/windows_installer.py | 61 ++++++++--- 5 files changed, 231 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 91c1272..9552611 100644 --- a/README.md +++ b/README.md @@ -48,19 +48,26 @@ Choose your operating system:
🪟 Windows -#### Automatic Installation (Recommended) - -1. **Download** the latest release from [GitHub](https://github.com/Viindoo/sign-client/releases) -2. **Extract** the ZIP file to your desired location -3. **Navigate** to the `install_script` folder -4. **Run** `windows.bat` -5. **Follow** the on-screen instructions - -#### Manual Installation - -1. Install **Python 3.10** from [Microsoft Store](https://apps.microsoft.com/store/detail/python-310/9PJPW5LDXLZ5) -2. Install **Microsoft Visual C++ 14** from [Microsoft](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist) -3. Run `python3.10 windows_installer.py` in the `install_script` folder +#### Installation Steps + +1. **Install Python 3.10** from [python.org](https://www.python.org/downloads/release/python-31011/) + - Download the Windows installer (64-bit) + - **IMPORTANT**: During installation, check **"Add Python to PATH"** + - After installation, restart your terminal/command prompt + +2. **Install Microsoft C++ Build Tools** from [Visual Studio Downloads](https://visualstudio.microsoft.com/visual-cpp-build-tools/) + - Download **"Build Tools"** + - During installation, select: + - **Desktop development with C++** (workload) + - **MSVC v143 - VS 2022 C++ x64/x86 build tools** (component) + - **Windows 11 SDK** (latest version) + +3. **Run the installer script** + - **Download** the latest release from [GitHub](https://github.com/Viindoo/sign-client/releases) + - **Extract** the ZIP file to your desired location + - **Navigate** to the `install_script` folder + - **Run** `windows.bat` + - The script will check prerequisites and set up the application #### After Installation diff --git a/install_script/create_shortcuts.ps1 b/install_script/create_shortcuts.ps1 index 1a95166..d9c0f91 100644 --- a/install_script/create_shortcuts.ps1 +++ b/install_script/create_shortcuts.ps1 @@ -1,3 +1,10 @@ +# PowerShell script to create desktop and start menu shortcuts + +$ErrorActionPreference = "Stop" + +Write-Host "=== Creating Shortcuts ===" -ForegroundColor Cyan +Write-Host "" + $WshShell = New-Object -comObject WScript.Shell # Get the application path @@ -6,23 +13,46 @@ $VBSPath = Join-Path $AppPath "run_hidden.vbs" # Create Desktop shortcut $DesktopPath = [Environment]::GetFolderPath("Desktop") -$Shortcut = $WshShell.CreateShortcut("$DesktopPath\Viindoo Sign Client.lnk") -$Shortcut.TargetPath = "wscript.exe" -$Shortcut.Arguments = """$VBSPath""" -$Shortcut.WorkingDirectory = $AppPath -$Shortcut.IconLocation = "$AppPath\app\assets\icon.ico" -$Shortcut.Description = "Viindoo Sign Client" -$Shortcut.Save() +$DesktopShortcutPath = "$DesktopPath\Viindoo Sign Client.lnk" + +try { + $Shortcut = $WshShell.CreateShortcut($DesktopShortcutPath) + $Shortcut.TargetPath = "wscript.exe" + $Shortcut.Arguments = """$VBSPath""" + $Shortcut.WorkingDirectory = $AppPath + $Shortcut.IconLocation = "$AppPath\app\assets\icon.ico" + $Shortcut.Description = "Viindoo Sign Client" + $Shortcut.Save() + Write-Host "Desktop shortcut created successfully!" -ForegroundColor Green +} catch { + Write-Host "Failed to create Desktop shortcut: $_" -ForegroundColor Red + exit 1 +} # Create Start Menu shortcut $StartMenuPath = [Environment]::GetFolderPath("StartMenu") $ProgramsPath = Join-Path $StartMenuPath "Programs" -$Shortcut = $WshShell.CreateShortcut("$ProgramsPath\Viindoo Sign Client.lnk") -$Shortcut.TargetPath = "wscript.exe" -$Shortcut.Arguments = """$VBSPath""" -$Shortcut.WorkingDirectory = $AppPath -$Shortcut.IconLocation = "$AppPath\app\assets\icon.ico" -$Shortcut.Description = "Viindoo Sign Client" -$Shortcut.Save() - -Write-Host "Shortcuts created successfully!" + +# Ensure Programs directory exists +if (-not (Test-Path $ProgramsPath)) { + New-Item -ItemType Directory -Path $ProgramsPath -Force | Out-Null +} + +$StartMenuShortcutPath = "$ProgramsPath\Viindoo Sign Client.lnk" + +try { + $Shortcut = $WshShell.CreateShortcut($StartMenuShortcutPath) + $Shortcut.TargetPath = "wscript.exe" + $Shortcut.Arguments = """$VBSPath""" + $Shortcut.WorkingDirectory = $AppPath + $Shortcut.IconLocation = "$AppPath\app\assets\icon.ico" + $Shortcut.Description = "Viindoo Sign Client" + $Shortcut.Save() + Write-Host "Start Menu shortcut created successfully!" -ForegroundColor Green +} catch { + Write-Host "Failed to create Start Menu shortcut: $_" -ForegroundColor Red + exit 1 +} + +Write-Host "" +Write-Host "=== Shortcuts created successfully! ===" -ForegroundColor Green diff --git a/install_script/macos_installer.py b/install_script/macos_installer.py index 40a71ff..69e58c5 100644 --- a/install_script/macos_installer.py +++ b/install_script/macos_installer.py @@ -2,7 +2,6 @@ import platform import stat import sys -import subprocess import shutil # Add parent directory to path to import app.utils diff --git a/install_script/windows.bat b/install_script/windows.bat index 71b97f0..a8c253c 100644 --- a/install_script/windows.bat +++ b/install_script/windows.bat @@ -1,55 +1,136 @@ @echo off +setlocal enabledelayedexpansion REM Viindoo Sign Client - Windows Installation Script -REM This script automatically installs Python 3.10 and dependencies for Windows +REM This script checks for prerequisites and sets up the application echo === Viindoo Sign Client - Windows Installer === -echo Installing dependencies for Windows... echo. +echo This script will check for prerequisites and set up the application. +echo. +echo Prerequisites required: +echo - Python 3.10 +echo - Microsoft C++ Build Tools +echo. + +REM Function to find Python 3.10 command (python or python3.10) +echo Checking for Python 3.10... +set PYTHON_CMD= -REM Check if Python 3.10 is installed +REM Try python3.10 first - check if it actually runs (not just alias) python3.10 --version >nul 2>&1 +if %ERRORLEVEL% EQU 0 ( + REM Check if it's actually Python 3.10 and not a redirect + for /f "tokens=*" %%v in ('python3.10 --version 2^>^&1') do ( + echo %%v | findstr /R "Python 3\.10\." >nul + if !ERRORLEVEL! EQU 0 ( + REM Verify it can actually execute Python code + python3.10 -c "import sys; exit(0 if sys.version_info[:2] == (3, 10) else 1)" >nul 2>&1 + if !ERRORLEVEL! EQU 0 ( + set PYTHON_CMD=python3.10 + echo [OK] Found Python 3.10 ^(python3.10^) + goto :python_found + ) + ) + ) +) + +REM Try python - check if it actually runs (not just alias) +python --version >nul 2>&1 +if %ERRORLEVEL% EQU 0 ( + REM Check if it's actually Python 3.10 and not a redirect to Store + for /f "tokens=*" %%v in ('python --version 2^>^&1') do ( + echo %%v | findstr /R "Python 3\.10\." >nul + if !ERRORLEVEL! EQU 0 ( + REM Verify it can actually execute Python code (not Store redirect) + python -c "import sys; exit(0 if sys.version_info[:2] == (3, 10) else 1)" >nul 2>&1 + if !ERRORLEVEL! EQU 0 ( + set PYTHON_CMD=python + echo [OK] Found Python 3.10 ^(python^) + goto :python_found + ) + ) + ) +) + +REM Python 3.10 not found +echo [ERROR] Python 3.10 is not installed. +echo. +echo Please install Python 3.10 manually: +echo 1. Download from: https://www.python.org/downloads/release/python-31011/ +echo 2. Run the installer ^(64-bit^) +echo 3. IMPORTANT: Check "Add Python to PATH" during installation +echo 4. Restart your terminal after installation +echo 5. Run this script again +echo. +pause +exit /b 1 + +:python_found +if not defined PYTHON_CMD ( + echo [ERROR] Error: Python 3.10 command not found. + pause + exit /b 1 +) + +REM Check for C++ Build Tools +echo. +echo Checking for Microsoft C++ Build Tools... +set CPP_TOOLS_FOUND=0 + +REM Check if vswhere.exe exists (Visual Studio Installer) +if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" ( + REM Use vswhere to check for C++ Build Tools + "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath >nul 2>&1 + if %ERRORLEVEL% EQU 0 ( + set CPP_TOOLS_FOUND=1 + echo [OK] Found Microsoft C++ Build Tools + ) +) + +if !CPP_TOOLS_FOUND! EQU 0 ( + echo [ERROR] Microsoft C++ Build Tools is not installed. + echo. + echo This is required for building some Python dependencies. + echo. + echo Please install Microsoft C++ Build Tools: + echo 1. Download from: https://visualstudio.microsoft.com/visual-cpp-build-tools/ + echo 2. Download "Build Tools" + echo 3. During installation, select: + echo - Desktop development with C++ ^(workload^) + echo - MSVC v143 - VS 2022 C++ x64/x86 build tools ^(component^) + echo - Windows 11 SDK ^(latest version^) + echo 4. After installation, run this script again + echo. + pause + exit /b 1 +) + +echo. +echo Running Python installer to setup application... +%PYTHON_CMD% windows_installer.py if %ERRORLEVEL% EQU 0 ( - echo ✅ Python 3.10 is already installed. echo. - echo Running Python installer to setup application... - python3.10 windows_installer.py + echo [OK] Python installer completed successfully! + echo. + echo Creating desktop and start menu shortcuts... + powershell -ExecutionPolicy Bypass -File "%~dp0create_shortcuts.ps1" if %ERRORLEVEL% EQU 0 ( + echo [OK] Shortcuts created successfully! echo. - echo ✅ Python installer completed successfully! + echo === Installation completed successfully! === + echo. + echo You can now run Viindoo Sign Client from: + echo - Desktop shortcut + echo - Start Menu + echo - Command line: %PYTHON_CMD% main.py echo. - echo Creating desktop and start menu shortcuts... - powershell -ExecutionPolicy Bypass -File "%~dp0create_shortcuts.ps1" - - if %ERRORLEVEL% EQU 0 ( - echo ✅ Shortcuts created successfully! - echo. - echo === Installation completed successfully! === - echo. - echo You can now run Viindoo Sign Client from: - echo - Desktop shortcut - echo - Start Menu - echo - Command line: python3.10 main.py - echo. - ) else ( - echo ❌ Error creating shortcuts. You can still run the application manually. - ) ) else ( - echo ❌ Python installer failed. Please check the error messages above. - pause - exit /b 1 + echo [ERROR] Error creating shortcuts. You can still run the application manually. ) ) else ( - echo ❌ Python 3.10 is not installed. - echo. - echo Please install Python 3.10 first: - echo 1. Open Microsoft Store - echo 2. Search for "python3.10" and install it - echo 3. Download and install Microsoft Visual C++ 14 from: - echo https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist - echo 4. Run this script again - echo. + echo [ERROR] Python installer failed. Please check the error messages above. pause exit /b 1 ) diff --git a/install_script/windows_installer.py b/install_script/windows_installer.py index 3df469d..36483ed 100644 --- a/install_script/windows_installer.py +++ b/install_script/windows_installer.py @@ -2,33 +2,72 @@ import stat import sys import platform +import subprocess # Add parent directory to path to import app.utils sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from app import utils +def check_python_version(): + """Check if Python version is exactly 3.10""" + if sys.version_info.major != 3 or sys.version_info.minor != 10: + raise Exception(f"Python 3.10 is required, but found {sys.version_info.major}.{sys.version_info.minor}") + def create_python_venv(): """Create Python virtual environment and install dependencies""" if os.path.exists(utils.python_venv_path): print('✅ Python virtual environment already exists, skipping...') return + python_cmd = sys.executable + print(f'Using Python command: {python_cmd}') + + # Normalize paths to handle spaces correctly + python_venv_path = os.path.normpath(utils.python_venv_path) + python_venv_exec_path = os.path.normpath(utils.python_venv_exec_path) + requirements_path = os.path.normpath(utils.requirements_path) + print('Creating Python virtual environment...') - os.system(f"python3.10 -m venv {utils.python_venv_path}") + # Use subprocess.run() instead of os.system() to handle paths with spaces correctly + result = subprocess.run( + [python_cmd, '-m', 'venv', python_venv_path], + check=False, + capture_output=True, + text=True + ) + if result.returncode != 0: + error_msg = result.stderr.strip() if result.stderr else result.stdout.strip() + raise Exception(f"Failed to create virtual environment. Exit code: {result.returncode}\nError: {error_msg}") + + # Verify venv was created successfully + if not os.path.exists(python_venv_exec_path): + raise Exception(f"Virtual environment created but python executable not found at: {python_venv_exec_path}") print('Upgrading pip and setuptools...') - os.system(f"{utils.python_venv_exec_path} -m pip install --upgrade pip setuptools") + result = subprocess.run( + [python_venv_exec_path, '-m', 'pip', 'install', '--upgrade', 'pip', 'setuptools'], + check=False, + capture_output=True, + text=True + ) + if result.returncode != 0: + error_msg = result.stderr.strip() if result.stderr else result.stdout.strip() + raise Exception(f"Failed to upgrade pip and setuptools. Exit code: {result.returncode}\nError: {error_msg}") print('Installing Python dependencies...') - os.system(f"{utils.python_venv_exec_path} -m pip install -r {utils.requirements_path}") + result = subprocess.run( + [python_venv_exec_path, '-m', 'pip', 'install', '-r', requirements_path], + check=False, + capture_output=True, + text=True + ) + if result.returncode != 0: + error_msg = result.stderr.strip() if result.stderr else result.stdout.strip() + raise Exception(f"Failed to install dependencies. Exit code: {result.returncode}\nError: {error_msg}") print('✅ Python virtual environment created successfully!') -def create_desktop_app(): - """Desktop app creation is handled by PowerShell script""" - print('Desktop shortcuts will be created by PowerShell script...') - def make_datadir(): """Create data directory and log file""" if os.path.exists(utils.data_dir_path): @@ -51,16 +90,14 @@ def main(): print("=== Viindoo Sign Client - Windows Python Installer ===") print(f"Running on: {platform.system()} {platform.release()}") print() - + + check_python_version() + try: # Create Python virtual environment create_python_venv() print() - # Create desktop app (handled by PowerShell) - create_desktop_app() - print() - # Create data directory make_datadir() print()