set / %variable%
Try it yourself →Defines and reads variables.
Syntax
set name=value · %name%
Description
Variables are assigned with set (NO spaces around =). Its value is read with %name%. There is no distinction between text and numbers.
Example
@echo off set name=HexLibrary echo Hello %name%
Expected output
Hello HexLibrary
When to use?
Data storage.
Common mistakes
- ⚠️ set name = value is WRONG (no spaces allowed); set name=value is correct.
- ⚠️ The value is read with %name%, NOT $name.