@echo off REM ============================================================ REM DFCode - Windows one-click installer (double-click me) REM ASCII launcher. Real work + Chinese messages: install_win.ps1 REM This window ALWAYS stays open at the end (no more flash-close). REM ============================================================ setlocal REM pushd (not "cd /d"): cd /d cannot enter a UNC path, so running this from a REM network share / redirected home folder used to fail here. pushd maps a temp REM drive letter for UNC and works in both cases. pushd "%~dp0" 2>nul set "EXPECTVER=2026.09.23.1" set "RC=1" if not exist "%~dp0install_win.ps1" ( echo [X] install_win.ps1 was not found next to this file. echo Keep install_win.bat and install_win.ps1 in the SAME folder. echo If you just re-downloaded, your browser may have saved it as echo "install_win ^(1^).ps1" - delete the old one and rename this to echo install_win.ps1. goto theend ) REM ---- Stale-script guard ------------------------------------------------- REM Re-downloading gives you "install_win (1).ps1" while this .bat still runs REM the OLD install_win.ps1 sitting in Downloads. Without this check a shipped REM fix silently does nothing and everyone concludes the fix did not work. findstr /C:"ScriptVersion = '%EXPECTVER%'" "%~dp0install_win.ps1" >nul 2>nul if errorlevel 1 ( echo [X] STOP: install_win.ps1 next to this file is NOT version %EXPECTVER%. echo You are probably running an old copy. Please delete BOTH files from echo your Downloads folder and download them again from the website. echo. goto theend ) REM ---- Group Policy pre-check -------------------------------------------- REM -ExecutionPolicy does NOT override Group Policy. On a GPO-locked machine the REM -File call below is refused outright, so any fallback message printed from REM inside install_win.ps1 would never be reached. Detect it out here instead, REM using -Command (not a script file => immune to the execution policy). REM (no pipes below on purpose: cmd does not process ^ escapes inside quotes, so REM a "^|" would reach PowerShell literally and blow up. Avoiding | sidesteps it.) powershell -NoProfile -NonInteractive -Command "$r=Get-ExecutionPolicy -List; $g=''; foreach($x in $r){ if(((([string]$x.Scope) -eq 'MachinePolicy') -or (([string]$x.Scope) -eq 'UserPolicy')) -and (((([string]$x.ExecutionPolicy) -eq 'Restricted')) -or ((([string]$x.ExecutionPolicy) -eq 'AllSigned')))){ $g='y' } }; if($g -ne ''){ exit 3 } else { exit 0 }" if errorlevel 3 ( echo ------------------------------------------------------------ echo [X] Your IT has locked PowerShell script execution via Group Policy. echo This installer cannot run on this machine, and the policy cannot echo be changed from your account. echo. echo Workaround - install from cmd.exe instead of PowerShell: echo npm.cmd install -g dfcode@latest --include=optional --registry=https://registry.npmjs.org echo and afterwards start DFCode from cmd.exe or Git Bash. echo. echo Or ask IT to allow RemoteSigned for developer accounts. echo ------------------------------------------------------------ goto theend ) REM Bypass here is intentional and safe: it only affects THIS process tree and is REM never persisted. Note it also makes install_win.ps1 blind to the machine's REM real policy - that script compensates deliberately; see its header. powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0install_win.ps1" set "RC=%errorlevel%" echo. echo ------------------------------------------------------------ echo Installer finished. Exit code: %RC% echo If you see errors above, please screenshot this whole window. echo ------------------------------------------------------------ :theend popd 2>nul echo. if "%DFCODE_NO_PAUSE%"=="1" exit /b %RC% echo Press any key to close this window . . . pause >nul exit /b %RC%