AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

batch-files

Expert-level Windows batch file (.bat/.cmd) skill for writing, debugging, and maintaining CMD scripts. Use when asked to "create a batch file", "write a .bat script", "automate a Windows task", "CMD scripting", "batch automation", "scheduled task script", "Windows shell script", or when working with .bat/.cmd files in the workspace. Covers cmd.exe syntax, environment variables, control flow, string processing, error handling, and integration with system tools.

Original source
github
License
MIT
Pinned revision
5269f7ea2d6c3a9bfda5ed878b6726cf509121fd

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read github--batch-files at revision 5269f7ea2d6c3a9bfda5ed878b6726cf509121fd, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 10

references/batch-files-and-functions.md

Batch Files, Scripts, and Functions

Utility Scripts

Run a Script — Use .CMD extension (preferred over .BAT). Edit in Notepad, run from command prompt or double-click. Use CALL between batch files. Detect launch mode with %CmdCmdLine%. Run PowerShell from CMD: powershell.exe -command "& {script}". Run VBScript: cscript //nologo script.vbs.

Banner — Display text in large ASCII art letters using SET commands. Build 7 rows of characters with variable assignment for each letter (a-z, 0-9, space, dash, period). Echo each row to compose the banner output.

Elevate/UAC — Run with elevated permissions. Methods: (1) Shortcut with "Run as Admin" checkbox, (2) VBScript/PowerShell elevation from command line, (3) Test elevation with FSUTIL or CACLS. Run WITHOUT elevation: SET __COMPAT_LAYER=RunAsInvoker. Fix current directory after elevation: pushd "%~dp0".

Date and Time

DateMath — Add/subtract days from any date using Julian Day Number calculation. Handles Y2K correctly. Supports date subtraction (difference in days) and date+days arithmetic. Uses SETLOCAL/ENDLOCAL with variable passback technique.

GetDate — Get current date independent of locale. Methods: (1) PowerShell get-date -format, (2) Robocopy timestamp parsing (most common), (3) date /t parsing, (4) DOFF.exe, (5) VBScript. Robocopy method creates a temp folder and parses the timestamp from ROBOCOPY /njh /njs.

GetTime — Returns current time into a variable. Handles any regional time delimiter by dynamically detecting separator characters. Ensures leading zero on hours for consistent formatting.

GetGMT — Calculate Greenwich Mean Time using WMIC Win32_LocalTime and Win32_UTCTime. Note: WMIC deprecated in Win10 21H1. PowerShell alternative: (Get-Date).ToUniversalTime().

TimeDiff — Calculate difference between two time values. Handles midnight rollover. Returns HH:MM:ss.hs format. Converts times to hundredths-of-second timecodes for arithmetic.

Timer — Measure elapsed time with Start/Stop/Lap modes using a temp stamp file. Calculates hours:minutes:seconds.hundredths. Handles regional time settings.

String and File Processing

DeQuote — Remove quotes from strings. Simplest: %~1 parameter extension. One-line: Set "var=%var:"=%". Function approach: FOR /F with %%~A. Can detect matched vs unmatched quotes.

Empty — Check if directory is empty: FOR /F %%A in ('dir /b /a "%folder%"') do goto NotEmpty. Alternative with dir /A:-D /B for files-only check. Not recursive for subdirectories.

GenChr — Generate any ASCII/Unicode character (0-255) as a .chr file using MAKECAB with the reserveperfoldersize trick. Handle codepage switching with CHCP.

StampMe — Rename file with date/time stamp using Robocopy timestamp parsing. Output format: [email protected]. Supports drag-and-drop (pass filename as %1).

StrLen — Calculate string length using binary search with FOR loop testing positions 4096, 2048, 1024...1. O(log n) performance. Returns length via variable or echo.

ToLower — Convert string to upper/lower case. Method 1: CALL SET with letter-by-letter replacement (handles umlauts/international chars). Method 2: simpler FOR loop with case-insensitive SET replacement.

File System

DelOlder — Delete files older than n days. Methods: (1) ForFiles /d -7, (2) Robocopy /move /minage:7, (3) DateMath.cmd with Julian Day comparison, (4) PowerShell .AddDays(-7).

IsDirectory — Check if path is file or directory using %~a1 attribute expansion. Check first character for d: Set "_attr=%~a1" & If "%_attr:~0,1%"=="d" (echo Directory). Raises ERRORLEVEL 1 if not found.

Whereis — Show full path to any executable. Tests for internal commands first, then searches PATH+PATHEXT. Handles quoted paths with spaces. Returns result via variable or echo.

xlong — List files exceeding MAX_PATH (260 chars). Uses DIR /b /s with substring check at position 256: If not "!name:~256,1!"=="" echo Extra long name: "%%a". PowerShell one-liner alternative: cmd /c dir /s /b | where-object{$_.length -gt 256}.

System and Configuration

ANSI Colours — Available by default in Windows 1909+. Foreground: Esc[30m (black) through Esc[97m (white). Background: Esc[40m through Esc[107m. Formatting: Esc[1m (bold), Esc[4m (underline), Esc[7m (reverse). Reset: Esc[0m. Save ESC to variable: for /f %%a in ('echo prompt $E^| cmd') do set "ESC=%%a". Supports 24-bit RGB in Win10. Enable on older Win10 via registry: [HKCU\Console] VirtualTerminalLevel=dword:1.

Autoexec and AutoRun — Autoexec.bat: legacy MS-DOS; under Windows, only SET statements in C:\autoexec.bat are parsed at boot. AutoRun commands: set HKCU\Software\Microsoft\Command Processor\AutoRun or HKLM equivalent to run commands when CMD opens (useful for DOSKEY macros). Startup locations: %appdata%\Microsoft\Windows\Start Menu\Programs\Startup\, HKCU\...\Run, HKLM\...\Run. Machine startup: use Task Scheduler with "When my computer starts". Disable AutoRun on drives: NoDriveTypeAutoRun registry key; fully disable with iniFileMapping method.

CMD Shell — Pause with Ctrl+S, cancel with Ctrl+C. Tab auto-completion enabled by default. Command history: F7 (list), F8 (search), F9 (by number). Quote processing: CMD strips leading/trailing quotes under specific conditions; use double quotes "" to preserve. Max command line: 8191 chars. Max path: 260 chars. Allow UNC paths: [HKLM\...\Command Processor] DisableUNCCheck=dword:1. .CMD vs .BAT: .CMD resets ERRORLEVEL after every command; .BAT only on error. %COMSPEC% shows which shell is running.

Internal Commands — Commands built into CMD.exe (no external .exe needed): ASSOC, BREAK, CALL, CD, CLS, COLOR, COPY, DATE, DEL, DIR, DPATH, ECHO, ENDLOCAL, ERASE, EXIT, FOR, FTYPE, GOTO, IF, KEYS, MD, MKLINK, MOVE, PATH, PAUSE, POPD, PROMPT, PUSHD, REM, REN, RD, SET, SETLOCAL, SHIFT, START, TIME, TITLE, TYPE, VER, VERIFY, VOL. External commands stored in C:\WINDOWS\System32. Arguments can be passed to internal commands; space before argument can be omitted at command line but include it in scripts.

App Compatibility — Set via registry at HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers (per-user) or HKLM (all users). Syntax: ~ [PrivilegeLevel] [Settings] [CompatibilityMode]. Privilege: RUNASADMIN. Settings: 256COLOR, 16BITCOLOR, 640X480, HIGHDPIAWARE, DPIUNAWARE, GDIDPISCALING DPIUNAWARE, DISABLEDXMAXIMIZEDWINDOWEDMODE. Modes: WIN95, WIN98, WINXPSP2, WINXPSP3, VISTARTM, VISTASP1, VISTASP2, WIN7RTM, WIN8RTM. Example: REG ADD "HKCU\...\AppCompatFlags\Layers" /V "%ProgramFiles%\app\app.exe" /T REG_SZ /D "~ RUNASADMIN WINXPSP2" /F.

Errorlevel and Exit Codes — Most commands return 0 for success. Max range: ±2147483647. Detection methods: (1) IF ERRORLEVEL n (legacy, means >= n), (2) IF %ERRORLEVEL% EQU 0 (preferred). Inside loops, use &&/|| conditional operators or enable DelayedExpansion for !ERRORLEVEL!. Commands that do NOT affect ERRORLEVEL: BREAK, ECHO, ENDLOCAL, FOR, IF, PAUSE, REM, RD, TITLE. Force ERRORLEVEL 1: (CALL). Reset to 0: (call ). Never SET ERRORLEVEL=... (creates user variable that shadows the pseudo-variable). .CMD scripts reset ERRORLEVEL after every internal command; .BAT scripts only on error.

Error Handling — Branch on success/failure with conditional operators: SomeCommand && (echo success) || (echo failed). Gotcha: if last command in success branch errors, the failure branch fires; end success block with (call ). For specific errors: IF %ERRORLEVEL% NEQ 0 (Echo Error &Exit /b 1). DEL returns 0 even on failure; Robocopy returns non-zero on success. For scheduled tasks, exiting with error code logs as failed task.

Display DPI — DPI = √(W² + H²) / ScreenSize. Win10 settings: Settings > Display > Scale and Layout (100-500%). Per-user DPI on terminal servers via registry. Don't set DPI below 96 (fonts break). Citrix: per-user DPI only via registry keys for 96/120/144 DPI.

OOBE — Setup Windows 11 without internet/Microsoft account. Win11 25H2: start ms-cxh:localonly from Shift+F10 CMD prompt during setup. Earlier Win11: OOBE\BYPASSNRO (restarts with "I don't have Internet" option). Manual method: add HKLM\...\OOBE BypassNRO=dword:1 via regedit. Custom user folder name (25H2): Shift+F10 during setup, cd oobe, run SetDefaultUserFolder.cmd, enter name (16 char max).

Recovery Environment — WinRE/Safe Mode/WinPE. Safe mode: hold Shift + Power > Restart, then Troubleshoot > Startup Settings > F4 (safe) or F5 (safe+networking). WinRE: repeatedly power-cycle (hold power 10s, 3 times). WinPE: boot from USB, runs wpeinit automatically. WinPE drive detection script: loop through drive letters A-Z checking for existence of a known file. Create admin account from recovery: rename utilman.exe, copy cmd.exe over it, reboot, click Ease of Access at login to get CMD, NET user demo-user password1 /add then NET localgroup administrators demo-user /add.

64-Bit Detection — Detect 64-bit OS: IF %PROCESSOR_ARCHITECTURE%==x86 (IF NOT DEFINED PROCESSOR_ARCHITEW6432 Set _os=32). Detect 32-bit process on 64-bit: check if PROCESSOR_ARCHITEW6432 is defined. System folders: 32-bit session sees System32 as 32-bit and SysNative as 64-bit; 64-bit session sees System32 as 64-bit and SysWOW64 as 32-bit. Relaunch as 64-bit: %SystemRoot%\Sysnative\cmd.exe /C "%~f0" %*. Run 32-bit: %SystemRoot%\SysWoW64\cmd.exe. Environment: %ProgramFiles% = 64-bit programs, %ProgramFiles(x86)% = 32-bit programs.

Networking and Security

Slow Network Browsing — Desktop.ini parsing slows folder listing; check with NET FILE | Find "desktop.ini" on file server. Fix: delete non-essential desktop.ini files or remove READ_ONLY permission. Corrupted profile permissions: rename C:\Users\<profile>\AppData\Local\Microsoft\Windows from another admin account. Network shortcuts on Desktop/Start menu cause slow refresh when resource unavailable; use explorer /e, \\Server\Share shortcut instead.

LAN Manager Authentication — Controls NTLM authentication levels 0-5 via HKLM\SYSTEM\CurrentControlSet\Control\LSA\LMCompatibilityLevel. NTLMv1 removed in Win11 24H2 and Server 2025. Default level 3 for current OS. Level 0-1: send LM+NTLM. Level 2: send NTLM only. Level 3+: send NTLMv2 only. Levels 4-5 on DC: refuse NTLMv1/LM responses. Increasing above 3 on server can lock out old clients.

Logon Types — Event ID 4624 types: 3=Network (remote file/printer access, credentials not cached), 4=Batch (scheduled tasks, credentials hit disk), 5=Service (service accounts, credentials in LSA secrets), 7=Unlock, 8=Network cleartext (IIS basic auth), 9=New credentials (RunAs /netonly), 10=Remote Interactive (RDP, credentials in lsass), 11=Cached Interactive (offline domain logon, mscache2 format).

File Shares Organization — Split Folder Sharing: two drive mappings per team — S: (Shared, visible to other teams) and T: (Team-only, hidden via Access-Based Enumeration). ABE hides folders user can't access; works well up to a few thousand shares but degrades at tens of thousands. Use two AD groups per team: one for T: drive, one for S: drive access. Home folders map to H: (top of list) or U: (bottom). Default sub-folders help users organize: Admin, Documentation, Meetings, Projects, Resources, Templates.

File Sharing Modes — When creating/opening files, specify FILE_SHARE_READ, FILE_SHARE_WRITE, both, or neither. Both processes must have compatible sharing modes. GENERIC_READ + FILE_SHARE_READ: share with any READ process that also has File_Share_Read. GENERIC_WRITE + FILE_SHARE_WRITE: share with any WRITE process that has File_Share_Write. Incompatible modes = file locked by first process.

NoDrives — Hide drive letters in Explorer via registry DWORD at HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDrives. Bitmask values: A=1, B=2, C=4, D=8... Z=33554432, ALL=67108863. Hidden drives still accessible by typing letter in address bar. Requires logoff/reboot. Hide disk space color bar: edit HKLM\Software\Classes\Drive\TileInfo and remove System.PercentFull;.

Built-In Groups and Special Identities — Key groups: Administrators (unrestricted access), Domain Admins (admin the domain), Enterprise Admins (forest-wide changes), Account Operators (limited account creation), Backup Operators (backup/restore all files), Server Operators (services, shares, shutdown on DCs). Special identities (implicit): Everyone, Authenticated Users, Interactive, Network, Batch, Service, Creator Owner, Anonymous Logon. Protected Users group provides additional credential protection. KRBTGT is the KDC service account. LocalSystem has full system access. LocalService and NetworkService run with limited privileges.

Active Directory Groups — Security groups: control resource access. Distribution groups: email lists only. Scopes: Global (domain-centric, nest users), Domain Local (assign resource permissions), Universal (simple, all-purpose, replicated to global catalog), Local (SAM-stored, single machine). Best practice: users in Global groups, nest in Domain Local groups for permissions (AGDLP). Single domains: Global groups can nest other Globals; Domain Local for resources prevents wrong-way permission inheritance. Group membership evaluated at logon — changes require re-authentication. Naming: use alphanumerics, dash, underscore; prefix with G- or T- for clarity.

Registry Tweaks (Win11) — Boot: disable lock screen NoLockScreen=1, verbose login verbosestatus=1. Explorer: Win10-style context menus (add InprocServer32 key), default to "This PC" LaunchTo=1, disable Thumbs.db DisableThumbnailCache=1, show hidden files Hidden=1, show file extensions HideFileExt=0. Start Menu: move to left TaskbarAl=0, remove Bing search BingSearchEnabled=0, speed up MenuShowDelay=250. Control Panel: allow appearance/display/screensaver changes, set lock screen wallpaper. Telemetry: disable Copilot/Recall TurnOffWindowsCopilot=1, disable diagnostics AllowTelemetry=0. Updates: auto-download+schedule AUOptions=4, notify only AUOptions=2, disable AUOptions=1.

Miscellaneous

Long Filenames and NTFS — Max path: 260 chars (MAX_PATH = drive + colon + backslash + 256 chars + null). Max filename: 256 chars. Access long paths with \\?\ prefix (disables normalization, allows up to 32,767 chars). Win10 1607+ can opt-in to remove MAX_PATH limit. .BAT vs .CMD: .CMD resets ERRORLEVEL consistently; .BAT does not. .BAT on 32-bit Windows may create .PIF files (security risk). Reserved names: CON, PRN, AUX, NUL, COM0-9, LPT0-9. Illegal chars: / \ : * ? " < > |. 8.3 filenames disabled by default since Win8/Server 2012; disable manually with FSUTIL behavior set disable8dot3 1. Path types: absolute C:\path, UNC \\server\share, device \\.\ or \\?\.

Percent Symbols (% vs %%) — In batch files, %% produces a single %. Parser logic: %%G → FOR parameter value; %1 → command line argument; %var% → variable. At the command line, only single % needed (no batch parameters to conflict). Never name variables with numbers (conflicts with %1 etc). SET /A modulus operator needs %% in batch files. Prefix variables with underscore to avoid numeric name conflicts.

Network Printing — Print$ hidden share delivers drivers to clients. Keep Printer Name and Share Name identical. Use short names (≤8 chars, no spaces) for portability. Printer pools: multiple devices as one virtual printer, routes to first available. Priority: create separate high-priority queue pointing to same device. Default printer is per-user, roams with profiles. LPR protocol for line printers and UNIX interop. Bulk migration with PRINTBRM. Delete stuck printers via registry: HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\<name>, then restart Print Spooler service. Location-aware printing auto-switches default by network.


Best Practices and Debugging

Batch File Scripting Techniques — Master index of batch scripting categories. Techniques classified as "DOS batch" (COMMAND.COM) or "NT batch" (CMD.EXE). Use COMMAND /C to invoke DOS batch techniques on NT systems. Categories: Best Practices, Debugging, Data/Variables, Devices, Elevation, Files, Folders, Internet, Inventory, Math, Miscellaneous, Network, Printing, Processes/Services, Program Flow, Registry, Samples, Schedulers, Security, Time/Date, UNIX Ports, User Interaction, Wildcards.

COMMAND.COM, SHELL and COMSPEC — COMMAND.COM is DOS 16-bit command interpreter. Syntax: COMMAND [drive:path] [device] [/C command | /K command] [/D] [/E:nnn] [/F] [/MSG] [/P] [/Y] [/Z]. /C closes session after exec, /K keeps session open, /P makes permanent, /E:nnn sets environment size (160–32768 bytes), /F enables fail-by-default (suppresses Abort/Retry/Fail), /Y step-through debug, /Z shows errorlevel of every command. SHELL command in CONFIG.SYS specifies primary interpreter. COMSPEC variable specifies secondary. CMD.EXE is 32-bit replacement for Windows NT 4+. Changes in secondary environment are lost when session closes.

DOs and DON'Ts When Writing Batch Files — DOs: (1) add comments, (2) validate input, (3) doublequote args "%~1", (4) doublequote paths (prevents code insertion exploits from ampersands/spaces), (5) consistent casing, (6) initialize variables, (7) use SETLOCAL/local variables, (8) pass data as subroutine arguments not globals, (9) multi-line indented code blocks in IF/FOR, (10) each command on its own line, (11) avoid one-liners with ampersands, (12) check external command availability/version, (13) specify extensions for externals, (14) specify full paths for externals, (15) debug even when working. DON'Ts: (1) no variables for command names, (2) no nested IF...ELSE, (3) no nested code blocks (use subroutines), (4) no @command hiding except @ECHO OFF, (5) no one-liners, (6) no clever tricks without documentation. Quote: "Debugging is always harder than programming, so if you write code as cleverly as you know how, by definition you will be unable to debug it."

Debugging Batch Files — Techniques: (1) Error messages — REM out @ECHO OFF, redirect all output to log mybatch.bat params > mybatch.log 2>&1, search log for errors. (2) Environment variables — insert SET MyVariable or ECHO %MyVariable% to check values, enable delayed expansion in FOR/code blocks. (3) Complex commands — simplify nested FIND/FINDSTR/FOR /F, test components individually, verify token positions. (4) Subroutines — add counter SET /A Counter += 1 at start, dump all vars with SET. (5) Windows versions — test with CMD.EXE copies from different OS versions (rename as cmdNT4.exe etc.), known issues: REG.EXE v3 vs v2, delayed expansion unavailable on NT4/early Win2K, SET /A integer range differences, NETSH options vary. Version control: VER | FIND "Windows NT".

Comments in Batch Files — Methods: (1) REM — standard, works everywhere, but slows COMMAND.COM on floppy. (2) :: double colons — faster (treated as invalid label, skipped), but MUST be at line start. BREAKS inside code blocks and FOR loops (causes ) was unexpected errors). Exception: single :: immediately followed by non-blank command works in code blocks. (3) Comment blocks — use GOTO EndComment/:EndComment, or EXIT at end of file, or ( without closing ) at file end. (4) %= inline comments =% syntax. Key pitfall: (REM comment & ECHO text) — REM treats everything including ) as comment, opening unmatched paren that eats rest of file. Pipe trick: REM | CHOICE /C:AB /T:A,5 > NUL blocks keyboard input (COMMAND.COM only; CMD.EXE uses TYPE NUL | CHOICE). Best practice: avoid comments inside code blocks; use REM if must; place comments before code blocks.

Input Validation and Security

Prevent Code Insertion Exploits — Batch files are "weakly typed": everything is a string, strings can be commands, no way to distinguish data from code. The %CD% vulnerability: ampersands in folder names cause code execution when %CD% is used unquoted. Solution: doublequote "%CD%" (safe because paths cannot contain doublequotes). For variables that CAN contain doublequotes, quoting does NOT solve the issue. Test batch files for unquoted %CD%: TYPE "%%~A" | FIND /I /N "%%CD" | FINDSTR /R /I /C:"[^""]%%CD[:%%]". Alternatives: use "%CD%", use . or .\ instead of %CD%, abort on ampersands: CD | FIND "&" && EXIT /B 1.

Command Line Input Validation — No fool-proof command line validation exists. Best method: ECHO "%~1"| FIND /I "TEST" (method 7, score 6/7) or ECHO "%~1"| FINDSTR /L /X /I """TEST""" (method 13, score 6.5/7). Weak point: "quotes within" — unterminated doublequotes combined with ampersands enable code insertion. %1 vs %~1: tilde strips surrounding quotes. Demonstration: passing test1"&test2= shows code insertion via unmatched quotes.

Parameter Files — Safer alternative to command line arguments. Plain text file with Parameter=Value per line. Validate with FINDSTR /R /C:"[()&'\"]" "parameterfile"to reject unwanted characters. Parse safe files withFOR /F "tokens=* delims==" %%A IN ('FINDSTR /R /X /C:"[^=][^=]=." "parameterfile"') DO SET Parameter.%%A. Singlequotes safe with usebackq` (but then backquotes are forbidden). For ampersands/doublequotes in input, consider VBScript or PowerShell instead.

Safely Using SET /P — SET /P "Input=prompt: " accepts keyboard input. Code insertion risk: input abc&ping ::1 causes ECHO %Input% to execute ping. Doublequoting "%Input%" fails against embedded doublequotes like abc"&ping ::1&echo "oops. Solution: use delayed variable expansion — SETLOCAL EnableDelayedExpansion then reference as !var!. Delayed expansion resolves at step 3 of command processing (after command splitting at step 2 where injection occurs), so special characters are no longer interpreted. Reject doublequotes: SET Input | FIND """" >NUL then IF NOT ERRORLEVEL 1 SET Input=. Test for all questionable chars: SET Input | FINDSTR /R /C:"[&""|()]". Alternative: use CHOICE for selection instead of free input.

Security Configuration with SeCEdit — Set permissions on files, folders, and registry keys using security templates. Create template via MMC snap-in (Security Templates), configure permissions in GUI, save as .inf file. Edit .inf to keep only changed sections ([Registry Keys], [File Security], [Version], [Profile Description]). Apply via: ECHO y| SECEDIT.EXE /CONFIGURE /CFG myprog.inf /DB dummy.sdb /OVERWRITE /AREAS REGKEYS FILESTORE /LOG myprog.log /QUIET. Doublequotes not allowed in SeCEdit commands — use 8.3 short names for paths with spaces. Test with /VERBOSE switch during development.

SubInACL Permissions Management — Microsoft utility for managing security on files, registry keys, services, shares, printers, and processes. Syntax: SubInAcl [/option...] /object_type object_name [/action[=parameter]...]. Object types: /file, /subdirectories, /keyreg, /subkeyreg, /service, /printer, /share, /process. Key actions: /grant=[Domain\]User[=Access], /revoke, /replace, /display, /setowner, /findsid, /changedomain. Access codes vary by type — File: F=Full, C=Change, R=Read, W=Write, X=Execute; Service: T=Start, O=Stop, P=Pause; Registry: Q=Query, S=Set Value, C=Create SubKey. Example: SUBINACL /verbose=1 /subdirectories "D:\folder" /grant=Users=R.

Variables and Data

The SET Command — Displays, sets, or removes environment variables. Basic: SET variable=value, delete: SET variable=, display prefix matches: SET P shows all vars starting with P. `SET /A expr