Status: mandatory standard for every new or refactored .bat / .cmd script in this repository.
Target environment: Windows CMD, executed from a local console with PowerShell available.
Goal: consistent, safe, UTF-8-friendly scripts with automatic UAC elevation and the Cyber Parking Zone interface.
- Start every script with the exact initialization sequence below:
@echo off, UTF-8 console activation, thencls. - Check elevation with
fltmc. If the process is not elevated, relaunch the same script throughpowershell -NoProfilewithStart-Process cmd.exe -ArgumentList '/c \"\"%~f0\"\"' -Verb RunAs(to safely support paths and filenames containing spaces and special characters like&); immediately terminate the unelevated process withexit /b. - After elevation, always force the working directory to the directory containing the script:
cd /d "%~dp0". Never rely on the inherited directory, because an elevated process may otherwise run fromC:\Windows\System32. - Set a descriptive
titlein the form<Script Purpose> - <MODE>so the running window is recognizable in the taskbar. - Render the Cyber Parking Zone before the main output: exactly four blank lines, one dark-gray 89-character parking line beginning with one leading space, then exactly three blank lines.
- Use yellow, 90-character PowerShell separator lines around each main execution stage. Keep normal status messages as plain English
echooutput. - Handle expected failures explicitly. Print a clear red PowerShell error message, preserve a meaningful non-zero exit code, and pause when interactive diagnostics are required.
- Finish successful runs with a yellow completion block,
timeout /t 10 /NOBREAK >nul, andexit /b 0. - Keep each file single-purpose. Use quoted
set "NAME=value"assignments for paths and values that may contain spaces. - Do not place secrets, credentials, tokens, personal paths, or host-specific values in this public repository. Retrieve them only from the private secrets source at execution time or use an approved local protected configuration file.
Copy this skeleton first, then replace placeholders without changing the initialization, elevation, directory, UI, or completion conventions.
:: ==========================================================================================
:: FILE: <Script_Name>.bat
:: ==========================================================================================
@echo off
chcp 65001 >nul
cls
:: Auto-elevate to Administrator
fltmc >nul 2>&1
if %errorlevel% neq 0 goto :ELEVATE
goto :ADMIN_OK
:ELEVATE
powershell -NoProfile -Command "Start-Process cmd.exe -ArgumentList '/c \"\"%~f0\"\"' -Verb RunAs"
exit /b
:ADMIN_OK
cd /d "%~dp0"
title <Script Purpose> - <MODE>
:: Cyber Parking Zone: 4 blank lines, 89-character line, 3 blank lines
for /L %%i in (1,1,4) do echo.
powershell -NoProfile -Command "Write-Host ' <89-character Cyber Parking Zone line goes here>' -ForegroundColor DarkGray"
for /L %%i in (1,1,3) do echo.
:: ------------------------------------------------------------------------------------------
:: MAIN SCRIPT EXECUTION
:: ------------------------------------------------------------------------------------------
powershell -NoProfile -Command "Write-Host '==========================================================================================' -ForegroundColor Yellow"
powershell -NoProfile -Command "Write-Host ' <Script Execution Started>' -ForegroundColor Yellow"
powershell -NoProfile -Command "Write-Host '==========================================================================================' -ForegroundColor Yellow"
echo.
:: Define configuration only after elevation and before the action.
set "EXAMPLE_PATH=C:\Path With Spaces"
:: Main commands go here. Status text must be in English.
echo Processing data, please wait...
:: Example failure pattern:
:: if %errorlevel% neq 0 (
:: powershell -NoProfile -Command "Write-Host ' ERROR: <meaningful failure message>' -ForegroundColor Red"
:: timeout /t 10 /NOBREAK >nul
:: exit /b 1
:: )
:: ------------------------------------------------------------------------------------------
:: END OF SCRIPT
:: ------------------------------------------------------------------------------------------
echo.
powershell -NoProfile -Command "Write-Host '==========================================================================================' -ForegroundColor Yellow"
powershell -NoProfile -Command "Write-Host ' Execution completed successfully!' -ForegroundColor Yellow"
powershell -NoProfile -Command "Write-Host '==========================================================================================' -ForegroundColor Yellow"
timeout /t 10 /NOBREAK >nul
exit /b 0
:: = Rooted by VladiMIR + AI | v.YYYY.MM.DD | github.com/GinCz =- Parking Zone: It is a visual buffer for any PowerShell invocation. Do not move, remove, or alter its spacing. The line must contain 89 characters including the mandatory leading space so it is visually centered in a 90-column console.
- Stage framing: Use the yellow separator before and after an operation, with a concise English label such as
Hiddify Portable Restore StartedorExecution completed successfully!. - Messages: Use
echofor normal progress andWrite-Hostonly when color is needed. Do not mix languages in user-facing messages within the same script. - Timing: Use
timeout /t <seconds> /NOBREAK >nul; do not use an unboundedpauseon a successful path.
- Validate required files, directories, commands, and prerequisites before destructive or long-running work.
- Quote every path and executable that can contain spaces.
- Stop or restart a process only when the script's purpose requires it; tolerate an already-stopped process where appropriate.
- For archive, download, installer, scheduled-task, registry, service, or network operations, check
%errorlevel%immediately after the command that must succeed. - Prefer idempotent operations: a rerun should either converge to the desired state or fail with a precise explanation.
- Do not suppress errors unless the failure is explicitly expected and handled.
- Use
-NoProfilefor every non-interactive PowerShell call to keep behavior deterministic. - Mandatory UTF-8 Encoding: All script files, configs, and generated code must strictly be saved in UTF-8 (without BOM) encoding.
Before committing a new or changed CMD script, verify:
- File encoding is strictly UTF-8 (without BOM).
- It starts with
@echo off,chcp 65001 >nul, andcls. - UAC self-elevation uses
fltmcand exits the original unelevated process. cd /d "%~dp0"executes only after elevation.- A meaningful title is present.
- The parking zone has exactly 4 blank lines above and 3 below; its line is exactly 89 characters with one leading space.
- Yellow UI separators are 90 characters wide.
- Status text is English and errors are clearly colored red.
- All paths are quoted and configuration uses
set "NAME=value". - Secrets are absent from public code, documentation, examples, command history, and commits.
- The script has explicit error handling and exits with
0on success or a non-zero status on failure. - The final 10-second timeout and
exit /b 0are present on the success path.
The Hiddify backup/restore scripts are the current functional reference for the intended elevation flow, parking-zone layout, yellow execution blocks, quoted variables, process handling, archive operations, and final timeout. Future refactoring should preserve their behavior while bringing their structure fully in line with this standard.
Maintainer: VladiMIR Bulantsev (GinCz)
Standard version: 2026.08.31