diff --git a/.codespellrc b/.codespellrc index 3098338eb..e022c1569 100644 --- a/.codespellrc +++ b/.codespellrc @@ -50,7 +50,9 @@ # Vertexes - FreeCAD shape sub-elements used as property of obj.Shape -ignore-words-list = numer,wit,aks,edn,ser,ois,gir,rouge,categor,aline,ative,afterall,deques,dateA,dateB,TE,FillIn,alle,vai,LOD,InOut,pixelX,aNULL,Wee,Sherif,queston,Vertexes,nin +# FO - tasklist option /FO to format running task output + +ignore-words-list = numer,wit,aks,edn,ser,ois,gir,rouge,categor,aline,ative,afterall,deques,dateA,dateB,TE,FillIn,alle,vai,LOD,InOut,pixelX,aNULL,Wee,Sherif,queston,Vertexes,nin,FO # Skip certain files and directories diff --git a/docs/README.skills.md b/docs/README.skills.md index 6041106cc..42f89c742 100644 --- a/docs/README.skills.md +++ b/docs/README.skills.md @@ -61,6 +61,7 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#adding-skills) for guidelines on how to | [azure-resource-visualizer](../skills/azure-resource-visualizer/SKILL.md) | Analyze Azure resource groups and generate detailed Mermaid architecture diagrams showing the relationships between individual resources. Use this skill when the user asks for a diagram of their Azure resources or help in understanding how the resources relate to each other. | `LICENSE.txt`
`assets/template-architecture.md` | | [azure-role-selector](../skills/azure-role-selector/SKILL.md) | When user is asking for guidance for which role to assign to an identity given desired permissions, this agent helps them understand the role that will meet the requirements with least privilege access and how to apply that role. | `LICENSE.txt` | | [azure-static-web-apps](../skills/azure-static-web-apps/SKILL.md) | Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development, configuring staticwebapp.config.json, adding Azure Functions APIs to SWA, or setting up GitHub Actions CI/CD for Static Web Apps. | None | +| [batch-files](../skills/batch-files/SKILL.md) | 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. | `assets/executable.txt`
`assets/library.txt`
`assets/task.txt`
`references/batch-files-and-functions.md`
`references/cygwin.md`
`references/msys2.md`
`references/tools-and-resources.md`
`references/windows-commands.md`
`references/windows-subsystem-on-linux.md` | | [bigquery-pipeline-audit](../skills/bigquery-pipeline-audit/SKILL.md) | Audits Python + BigQuery pipelines for cost safety, idempotency, and production readiness. Returns a structured report with exact patch locations. | None | | [boost-prompt](../skills/boost-prompt/SKILL.md) | Interactive prompt refinement workflow: interrogates scope, deliverables, constraints; copies final markdown to clipboard; never writes code. Requires the Joyride extension. | None | | [breakdown-epic-arch](../skills/breakdown-epic-arch/SKILL.md) | Prompt for creating the high-level technical architecture for an Epic, based on a Product Requirements Document. | None | diff --git a/skills/batch-files/SKILL.md b/skills/batch-files/SKILL.md new file mode 100644 index 000000000..73005d4ed --- /dev/null +++ b/skills/batch-files/SKILL.md @@ -0,0 +1,554 @@ +--- +name: batch-files +description: '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.' +--- + +# Batch Files + +A comprehensive skill for creating, editing, debugging, and maintaining Windows batch files (.bat/.cmd) using cmd.exe. Applies to CLI tool development, system administration automation, scheduled tasks, file operations scripting, and PATH-based executable scripts. + +## When to Use This Skill + +- Creating or editing `.bat` or `.cmd` files +- Automating Windows tasks (file operations, deployments, backups) +- Building CLI tools intended for a `bin/` folder on PATH +- Writing scheduled task scripts (SCHTASKS, Task Scheduler) +- Debugging batch script issues (variable expansion, error levels, quoting) +- Integrating batch scripts with external tools (curl, git, Node.js, Python) +- Scaffolding new batch-based projects with structured templates + +## Prerequisites + +- Windows NT-based OS (Windows 7 or later) +- cmd.exe (built-in) +- Optional: a `bin/` directory on PATH for distributing scripts as commands +- Optional: PATHEXT configured to include `.BAT;.CMD` (default on Windows) + +## Command Interpretation + +cmd.exe processes each line through four stages in order: + +1. **Variable substitution** — `%VAR%` tokens are replaced with environment variable values. `%0`–`%9` reference batch arguments. `%*` expands to all arguments. +2. **Quoting and escaping** — Caret `^` escapes special characters (`& | < > ^`). Quotation marks prevent interpretation of enclosed special characters. In batch files, `%%` yields a literal `%`. +3. **Syntax parsing** — Lines are split into pipelines (`|`), compound commands (`&`, `&&`, `||`), and parenthesized groups `( )`. +4. **Redirection** — `>` overwrites, `>>` appends, `<` reads input, `2>` redirects stderr, `2>&1` merges stderr into stdout, `>NUL` discards output. + +## Variables + +### Environment Variables + +```bat +set _MY_VAR=Hello World +echo %_MY_VAR% +set _MY_VAR= +``` + +- `set` with no arguments lists all variables +- `set _PREFIX` lists variables starting with `_PREFIX` +- No spaces around `=` — `set name = val` sets variable `"name "` to `" val"` + +### Special Variables + +| Variable | Value | +|----------|-------| +| `%CD%` | Current directory | +| `%DATE%` | System date (locale-dependent) | +| `%TIME%` | System time HH:MM:SS.mm | +| `%RANDOM%` | Pseudorandom number 0–32767 | +| `%ERRORLEVEL%` | Exit code of last command | +| `%USERNAME%` | Current user name | +| `%USERPROFILE%` | Current user profile path | +| `%TEMP%` / `%TMP%` | Temporary file directory | +| `%PATHEXT%` | Executable extensions list | +| `%COMSPEC%` | Path to cmd.exe | + +### Scoping with SETLOCAL / ENDLOCAL + +```bat +setlocal +set _LOCAL_VAR=scoped value +endlocal +REM _LOCAL_VAR is no longer defined here +``` + +To return a value from a scoped block: + +```bat +endlocal & set _RESULT=%_LOCAL_VAR% +``` + +### Delayed Expansion + +Variables inside parenthesized blocks are expanded at parse time. Use delayed expansion for runtime evaluation: + +```bat +setlocal EnableDelayedExpansion +set _COUNT=0 +for /l %%i in (1,1,5) do ( + set /a _COUNT+=1 + echo !_COUNT! +) +endlocal +``` + +- `!VAR!` expands at execution time (delayed) +- `%VAR%` expands at parse time (immediate) + +## Control Flow + +### Conditional Execution + +```bat +if exist "output.txt" echo File found +if not defined _MY_VAR echo Variable not set +if "%_STATUS%"=="ready" (echo Go) else (echo Wait) +if %ERRORLEVEL% neq 0 echo Command failed +``` + +Comparison operators: `equ`, `neq`, `lss`, `leq`, `gtr`, `geq`. Use `/i` for case-insensitive string comparison. + +### Compound Commands + +```bat +command1 & command2 & REM Always run both +command1 && command2 & REM Run command2 only if command1 succeeds +command1 || command2 & REM Run command2 only if command1 fails +``` + +### FOR Loops + +```bat +REM Iterate over a set of values +for %%i in (alpha beta gamma) do echo %%i + +REM Numeric range: start, step, end +for /l %%i in (1,1,10) do echo %%i + +REM Files in a directory +for %%f in (*.txt) do echo %%f + +REM Recursive file search +for /r %%f in (*.log) do echo %%f + +REM Directories only +for /d %%d in (*) do echo %%d + +REM Parse command output +for /f "tokens=1,2 delims=:" %%a in ('ipconfig ^| findstr "IPv4"') do echo %%b + +REM Parse file lines +for /f "usebackq tokens=*" %%a in ("data.txt") do echo %%a +``` + +### GOTO and Labels + +```bat +goto :main_logic +:usage +echo Usage: %~nx0 [options] +exit /b 1 + +:main_logic +echo Running main logic... +goto :eof +``` + +`goto :eof` exits the current batch or subroutine. Labels start with `:`. + +## Command-Line Arguments + +| Syntax | Value | +|--------|-------| +| `%0` | Script name as invoked | +| `%1`–`%9` | Positional arguments | +| `%*` | All arguments (unaffected by SHIFT) | +| `%~1` | Argument 1 with enclosing quotes removed | +| `%~f1` | Full path of argument 1 | +| `%~d1` | Drive letter of argument 1 | +| `%~p1` | Path (without drive) of argument 1 | +| `%~n1` | File name (no extension) of argument 1 | +| `%~x1` | Extension of argument 1 | +| `%~dp0` | Drive and path of the batch file itself | +| `%~nx0` | File name with extension of the batch file | +| `%~z1` | File size of argument 1 | +| `%~$PATH:1` | Search PATH for argument 1 | + +### Argument Parsing Pattern + +```bat +:parse_args +if "%~1"=="" goto :args_done +if /i "%~1"=="--help" goto :usage +if /i "%~1"=="--output" ( + set "_OUTPUT_DIR=%~2" + shift +) +shift +goto :parse_args +:args_done +``` + +## String Processing + +### Substrings + +```bat +set _STR=Hello World +echo %_STR:~0,5% & REM "Hello" +echo %_STR:~6% & REM "World" +echo %_STR:~-5% & REM "World" +echo %_STR:~0,-6% & REM "Hello" +``` + +### Search and Replace + +```bat +set _STR=Hello World +echo %_STR:World=Earth% & REM "Hello Earth" +echo %_STR:Hello=% & REM " World" (remove "Hello") +``` + +### Substring Containment Test + +```bat +if not "%_STR:World=%"=="%_STR%" echo Contains "World" +``` + +## Functions + +Functions use labels, CALL, and SETLOCAL/ENDLOCAL: + +```bat +@echo off +call :greet "Jane Doe" +echo Result: %_GREETING% +exit /b 0 + +:greet +setlocal +set "_MSG=Hello, %~1" +endlocal & set "_GREETING=%_MSG%" +exit /b 0 +``` + +- `call :label args` invokes a function +- `exit /b` returns from the function (not the script) +- Use the `endlocal & set` trick to pass values out of a scoped block + +## Arithmetic + +`set /a` performs 32-bit signed integer arithmetic: + +```bat +set /a _RESULT=10 * 5 + 3 +set /a _COUNTER+=1 +set /a _REMAINDER=14 %% 3 & REM Use %% for modulo in batch files +set /a _BITS="255 & 0x0F" & REM Bitwise AND +``` + +Supported operators: `+ - * / %% ( )` and bitwise `& | ^ ~ << >>`. + +Hexadecimal (`0xFF`) and octal (`077`) literals are supported. + +## Error Handling + +### Error Level Conventions + +- `0` = success +- Non-zero = failure (typically `1`) + +```bat +mycommand.exe +if %ERRORLEVEL% neq 0 ( + echo ERROR: mycommand failed with code %ERRORLEVEL% + exit /b %ERRORLEVEL% +) +``` + +### Fail-Fast Pattern + +```bat +command1 || (echo command1 failed & exit /b 1) +command2 || (echo command2 failed & exit /b 1) +``` + +### Setting Exit Codes + +```bat +exit /b 0 & REM Return success from a batch/function +exit /b 1 & REM Return failure +cmd /c "exit /b 42" & REM Set ERRORLEVEL to 42 inline +``` + +## Essential Commands Reference + +### File Operations + +| Command | Purpose | +|---------|---------| +| `DIR` | List directory contents | +| `COPY` | Copy files | +| `XCOPY` | Extended copy with subdirectories (legacy) | +| `ROBOCOPY` | Robust copy with retry, mirror, logging | +| `MOVE` | Move or rename files | +| `DEL` | Delete files | +| `REN` | Rename files | +| `MD` / `MKDIR` | Create directories | +| `RD` / `RMDIR` | Remove directories | +| `MKLINK` | Create symbolic or hard links | +| `ATTRIB` | View or set file attributes | +| `TYPE` | Print file contents | +| `MORE` | Paginated file display | +| `TREE` | Display directory structure | +| `REPLACE` | Replace files in destination with source | +| `COMPACT` | Show or set NTFS compression | +| `EXPAND` | Extract from .cab files | +| `MAKECAB` | Create .cab archives | +| `TAR` | Create or extract tar archives | + +### Text Search and Processing + +| Command | Purpose | +|---------|---------| +| `FIND` | Search for literal strings | +| `FINDSTR` | Search with limited regular expressions | +| `SORT` | Sort lines alphabetically | +| `CLIP` | Copy piped input to clipboard | +| `FC` | Compare two files | +| `COMP` | Binary file comparison | +| `CERTUTIL` | Encode/decode Base64, compute hashes | + +### System Information + +| Command | Purpose | +|---------|---------| +| `SYSTEMINFO` | Full system configuration | +| `HOSTNAME` | Display computer name | +| `VER` | Windows version | +| `WHOAMI` | Current user and group info | +| `TASKLIST` | List running processes | +| `TASKKILL` | Terminate processes | +| `WMIC` | WMI queries (drives, OS, memory) | +| `SC` | Service control (query, start, stop) | +| `DRIVERQUERY` | List installed drivers | +| `REG` | Registry operations (query, add, delete) | +| `SETX` | Set persistent environment variables | + +### Network + +| Command | Purpose | +|---------|---------| +| `PING` | Test network connectivity | +| `IPCONFIG` | IP configuration | +| `NSLOOKUP` | DNS lookup | +| `NETSTAT` | Network connections and ports | +| `TRACERT` | Trace route to host | +| `NET USE` | Map/disconnect network drives | +| `NET USER` | Manage user accounts | +| `NETSH` | Network configuration utility | +| `ARP` | ARP cache management | +| `ROUTE` | Routing table management | +| `CURL` | HTTP requests (Windows 10+) | +| `SSH` | Secure shell (Windows 10+) | + +### Scheduling and Automation + +| Command | Purpose | +|---------|---------| +| `SCHTASKS` | Create and manage scheduled tasks | +| `TIMEOUT` | Wait N seconds (Vista+) | +| `START` | Launch programs asynchronously | +| `RUNAS` | Run as different user | +| `SHUTDOWN` | Shutdown or restart | +| `FORFILES` | Find files by date and execute commands | + +### Shell Utilities + +| Command | Purpose | +|---------|---------| +| `WHERE` | Locate executables in PATH | +| `DOSKEY` | Create command macros | +| `CHOICE` | Prompt for single-key input | +| `MODE` | Configure console size and ports | +| `SUBST` | Map folder to drive letter | +| `CHCP` | Get or set console code page | +| `COLOR` | Set console colors | +| `TITLE` | Set console window title | +| `ASSOC` / `FTYPE` | File type associations | + +## Shell Syntax and Expressions + +### Parentheses for Grouping + +Parentheses turn compound commands into a single unit for redirection or conditional execution: + +```bat +(echo Line 1 & echo Line 2) > output.txt +if exist "data.csv" ( + echo Processing... + call :process "data.csv" +) else ( + echo No data found. +) +``` + +### Escape Characters + +The caret `^` escapes the next character: + +```bat +echo Total ^& Summary & REM Outputs: Total & Summary +echo 100%% complete & REM Outputs: 100% complete (in batch) +echo Line one^ +Line two & REM Caret escapes the newline +``` + +After a pipe, triple caret is needed: `echo x ^^^& y | findstr x` + +### Wildcards + +- `*` matches any sequence of characters +- `?` matches a single character (or zero at end of period-free segment) + +```bat +dir *.txt & REM All .txt files +ren *.jpeg *.jpg & REM Bulk rename +``` + +### Redirection Summary + +```bat +command > file.txt & REM Overwrite stdout to file +command >> file.txt & REM Append stdout to file +command 2> errors.log & REM Redirect stderr +command > all.log 2>&1 & REM Merge stderr into stdout +command < input.txt & REM Read stdin from file +command > NUL 2>&1 & REM Discard all output +``` + +## Writing Production-Quality Batch Files + +### Standard Script Structure + +```bat +@echo off +setlocal EnableDelayedExpansion + +REM ============================================================ +REM Script: example.bat +REM Purpose: Describe what this script does +REM ============================================================ + +call :main %* +exit /b %ERRORLEVEL% + +:main + call :parse_args %* + if not defined _TARGET ( + echo ERROR: --target is required. 1>&2 + call :usage + exit /b 1 + ) + echo Processing: %_TARGET% + exit /b 0 + +:parse_args + if "%~1"=="" exit /b 0 + if /i "%~1"=="--target" set "_TARGET=%~2" & shift + if /i "%~1"=="--help" call :usage & exit /b 0 + shift + goto :parse_args + +:usage + echo Usage: %~nx0 --target ^ [--help] + echo. + echo Options: + echo --target Path to process (required) + echo --help Show this help message + exit /b 0 +``` + +### Best Practices + +1. **Always start with `@echo off` and `setlocal`** — Prevents noisy output and variable leakage to the caller. +2. **Validate inputs before processing** — Check required arguments and file existence early. Use `if not defined` and `if not exist`. +3. **Quote paths and variables** — Use `"%~1"` and `"%_MY_PATH%"` to handle spaces and special characters safely. +4. **Use `exit /b` instead of `exit`** — Avoids closing the parent console window. +5. **Return meaningful exit codes** — `exit /b 0` for success, non-zero for specific failures. +6. **Use `%~dp0` for script-relative paths** — Ensures the script works regardless of the caller's working directory. +7. **Prefer `ROBOCOPY` over `XCOPY`** — More reliable, supports retry, mirroring, and logging. +8. **Use `EnableDelayedExpansion` when modifying variables inside loops or parenthesized blocks.** +9. **Write errors to stderr** — `echo ERROR: message 1>&2` keeps stdout clean for piping. +10. **Use `REM` for comments** — `::` can cause issues inside `FOR` loop bodies. + +### Security Considerations + +- **Never store credentials in batch files** — Use environment variables, credential stores, or prompts. +- **Validate user input** — Unquoted variables containing `&`, `|`, or `>` can inject commands. Always quote: `"%_USER_INPUT%"`. +- **Use `SETLOCAL`** — Prevents variable values from leaking to parent processes. +- **Sanitize file paths** — Validate paths before passing to `DEL`, `RD`, or `ROBOCOPY` to prevent unintended deletion. +- **Avoid `SET /P` for sensitive input** — Input is visible and stored in console history. Use a dedicated credential tool when possible. + +## Debugging and Troubleshooting + +| Technique | How | +|-----------|-----| +| Trace execution | Remove `@echo off` or use `@echo on` temporarily | +| Step through | Add `PAUSE` between sections | +| Check error level | `echo Exit code: %ERRORLEVEL%` after each command | +| Inspect variables | `set _MY_` to list all variables starting with `_MY_` | +| Delayed expansion issues | Variable inside `( )` block not updating? Enable `!VAR!` syntax | +| FOR loop `%%` vs `%` | Use `%%i` in batch files, `%i` on the command line | +| Spaces in SET | `set name=value` not `set name = value` | +| Caret in pipes | After a pipe, use `^^^` to escape special chars | +| Parentheses in SET /A | Escape with `^(` and `^)` inside `if` blocks, or use quotes | +| Double percent for modulo | `set /a r=14 %% 3` in batch files | + +## Cross-Platform and Extended Tools + +When batch scripting reaches its limits, these tools extend cmd.exe capabilities: + +| Tool | Purpose | +|------|---------| +| **Cygwin** | Full POSIX environment on Windows (grep, sed, awk, ssh) | +| **MSYS2** | Lightweight Unix tools and package manager (pacman) | +| **WSL** | Windows Subsystem for Linux — run native Linux binaries | +| **GnuWin32** | Individual GNU utilities as native Windows executables | +| **PowerShell** | Modern Windows scripting with .NET integration | + +Use batch when you need: fast startup, simple file operations, PATH-based CLI tools, or Task Scheduler integration. Consider PowerShell or WSL for complex data processing, REST APIs, or object-oriented scripting. + +## CMD Keyboard Shortcuts + +| Shortcut | Action | +|----------|--------| +| `Tab` | Auto-complete file/folder names | +| `Up` / `Down` | Navigate command history | +| `F7` | Show command history popup | +| `F3` | Repeat last command | +| `Esc` | Clear current line | +| `Ctrl+C` | Cancel running command | +| `Alt+F7` | Clear command history | + +## Reference Files + +The `references/` folder contains detailed documentation: + +| File | Contents | +|------|----------| +| `tools-and-resources.md` | Windows tools, utilities, package managers, terminals | +| `batch-files-and-functions.md` | Example scripts, techniques, best practices links | +| `windows-commands.md` | Comprehensive A-Z Windows command reference | +| `cygwin.md` | Cygwin user guide and FAQ | +| `msys2.md` | MSYS2 installation, packages, and environments | +| `windows-subsystem-on-linux.md` | WSL setup, commands, and documentation | + +## Asset Templates + +The `assets/` folder contains starter batch file template data, but as text files: + +| Template | Purpose | +|----------|---------| +| `executable.txt` | Standalone CLI tool with argument parsing | +| `library.txt` | Reusable function library with CALL-able labels | +| `task.txt` | Scheduled task / automation script | diff --git a/skills/batch-files/assets/executable.txt b/skills/batch-files/assets/executable.txt new file mode 100644 index 000000000..9b2ab2aa8 --- /dev/null +++ b/skills/batch-files/assets/executable.txt @@ -0,0 +1,171 @@ +@echo off +REM myTool +:: A standalone command-line tool template with argument parsing. +:: +:: usage: myTool [options] [1] [2] +:: [1] = input file path or value +:: [2] = output file path (optional) +:: +:: options: +:: /? Show this help message +:: -h Show this help message +:: --help Show this help message +:: -v Show version information +:: --verbose Enable verbose output +:: +:: examples: +:: > myTool "C:\data\input.txt" +:: > myTool "C:\data\input.txt" "C:\data\output.txt" +:: > myTool --verbose "C:\data\input.txt" +:: +set "_helpLinesMyTool=19" + +:: ======================================================================== +:: TEMPLATE INSTRUCTIONS +:: 1. Find/Replace "myTool" with your executable name (camelCase). +:: 2. Find/Replace "MyTool" with your executable name (PascalCase). +:: 3. Update the help block above (lines 2-19) for your tool. +:: 4. Implement your logic in :_runMyTool. +:: 5. Add any new variables to :_removeBatchVariablesMyTool. +:: ======================================================================== + +:: Config variables. +set "_versionMyTool=1.0.0" +set "_verboseMyTool=0" + +:: Define paths. +set "_scriptDirMyTool=%~dp0" +set "_scriptNameMyTool=%~n0" + +:: Parse arguments into variables. +set "_parOneMyTool=%~1" +set "_checkParOneMyTool=-%_parOneMyTool%-" +set "_parTwoMyTool=%~2" +set "_checkParTwoMyTool=-%_parTwoMyTool%-" +set "_parThreeMyTool=%~3" +set "_checkParThreeMyTool=-%_parThreeMyTool%-" + +:: ----------------------------------------------------------------------- +:: Handle help and version flags. +:: ----------------------------------------------------------------------- +if "%_parOneMyTool%"=="/?" call :_showHelpMyTool & goto _removeBatchVariablesMyTool +if /i "%_parOneMyTool%"=="-h" call :_showHelpMyTool & goto _removeBatchVariablesMyTool +if /i "%_parOneMyTool%"=="--help" call :_showHelpMyTool & goto _removeBatchVariablesMyTool +if /i "%_parOneMyTool%"=="-v" ( + echo %_scriptNameMyTool% version %_versionMyTool% + goto _removeBatchVariablesMyTool +) + +:: ----------------------------------------------------------------------- +:: Handle --verbose flag (shift arguments if present). +:: ----------------------------------------------------------------------- +if /i "%_parOneMyTool%"=="--verbose" ( + set "_verboseMyTool=1" + set "_parOneMyTool=%~2" + set "_checkParOneMyTool=-%~2-" + set "_parTwoMyTool=%~3" + set "_checkParTwoMyTool=-%~3-" +) + +:: Create temp directory for intermediate files. +call :_makeTempDirMyTool + +:: ----------------------------------------------------------------------- +:: Validate required input and start execution. +:: ----------------------------------------------------------------------- +if "%_checkParOneMyTool%"=="--" ( + echo ERROR: No input specified. Run "%_scriptNameMyTool% /?" for usage. 1>&2 + goto _removeBatchVariablesMyTool +) + +call :_startMyTool +goto _removeBatchVariablesMyTool + +:: ======================================================================== +:: MAIN LOGIC +:: ======================================================================== + +:_startMyTool + if "%_verboseMyTool%"=="1" ( + echo [VERBOSE] Input: %_parOneMyTool% + echo [VERBOSE] Output: %_parTwoMyTool% + ) + + REM Validate input file exists. + if NOT EXIST "%_parOneMyTool%" ( + echo ERROR: Input file not found: %_parOneMyTool% 1>&2 + goto :eof + ) + + call :_runMyTool +goto :eof + +:_runMyTool + REM =================================================================== + REM TODO: Replace this section with your tool's logic. + REM =================================================================== + echo Processing: %_parOneMyTool% + + if NOT "%_checkParTwoMyTool%"=="--" ( + echo Output to: %_parTwoMyTool% + REM Example: copy input to output. + REM copy /Y "%_parOneMyTool%" "%_parTwoMyTool%" >nul + ) + + echo Done. +goto :eof + +:: ======================================================================== +:: SUPPORT FUNCTIONS +:: ======================================================================== + +:_showHelpMyTool + echo: + for /f "skip=1 delims=" %%a in ('findstr /n "^" "%~f0"') do ( + set "_line=%%a" + setlocal EnableDelayedExpansion + for /f "delims=:" %%n in ("!_line!") do set "_lineNum=%%n" + if !_lineNum! GTR %_helpLinesMyTool% ( + endlocal + goto :eof + ) + set "_text=!_line:*:=!" + if defined _text ( + echo !_text:~4! + ) else ( + echo: + ) + endlocal + ) +goto :eof + +:_makeTempDirMyTool + set "_tmpDirMyTool=%TEMP%\%~n0_%RANDOM%%RANDOM%" + set "_tmpDirCreatedMyTool=0" + if NOT EXIST "%_tmpDirMyTool%" ( + mkdir "%_tmpDirMyTool%" >nul 2>nul + set "_tmpDirCreatedMyTool=1" + ) +goto :eof + +:: ======================================================================== +:: CLEANUP — Remove all batch variables. +:: ======================================================================== +:_removeBatchVariablesMyTool + set _helpLinesMyTool= + set _versionMyTool= + set _verboseMyTool= + set _scriptDirMyTool= + set _scriptNameMyTool= + set _parOneMyTool= + set _checkParOneMyTool= + set _parTwoMyTool= + set _checkParTwoMyTool= + set _parThreeMyTool= + set _checkParThreeMyTool= + REM Append new variables above this line. + + if "%_tmpDirCreatedMyTool%"=="1" if EXIST "%_tmpDirMyTool%" rmdir /S /Q "%_tmpDirMyTool%" >nul 2>nul + set _tmpDirMyTool= + set _tmpDirCreatedMyTool= + exit /b diff --git a/skills/batch-files/assets/library.txt b/skills/batch-files/assets/library.txt new file mode 100644 index 000000000..81f6a6703 --- /dev/null +++ b/skills/batch-files/assets/library.txt @@ -0,0 +1,188 @@ +@echo off +REM myLib +:: A reusable function library with CALL-able labels. +:: +:: usage: call myLib [function] [args...] +:: Functions: +:: trimWhitespace [inputVar] Trim leading/trailing spaces +:: toLower [inputVar] Convert value to lowercase +:: getTimestamp [outputVar] Get current date-time stamp +:: logMessage [level] [message] Write a log entry +:: padRight [string] [width] Right-pad a string with spaces +:: +:: examples: +:: > set "myVar= Hello World " +:: > call myLib trimWhitespace myVar +:: > call myLib getTimestamp _now +:: > call myLib logMessage INFO "Acme Corp backup started" +:: +set "_helpLinesMyLib=17" + +:: ======================================================================== +:: TEMPLATE INSTRUCTIONS +:: 1. Find/Replace "myLib" with your library name (camelCase). +:: 2. Find/Replace "MyLib" with your library name (PascalCase). +:: 3. Add your own :_funcNameMyLib labels below. +:: 4. Update the help block above (lines 2-17) for your library. +:: 5. Add any new variables to :_removeBatchVariablesMyLib. +:: ======================================================================== + +:: Route to the requested function. +set "_funcMyLib=%~1" +set "_argOneMyLib=%~2" +set "_argTwoMyLib=%~3" +set "_argThreeMyLib=%~4" + +if "%_funcMyLib%"=="/?" call :_showHelpMyLib & goto _removeBatchVariablesMyLib +if /i "%_funcMyLib%"=="-h" call :_showHelpMyLib & goto _removeBatchVariablesMyLib +if /i "%_funcMyLib%"=="--help" call :_showHelpMyLib & goto _removeBatchVariablesMyLib + +if /i "%_funcMyLib%"=="trimWhitespace" call :_trimWhitespaceMyLib & goto _removeBatchVariablesMyLib +if /i "%_funcMyLib%"=="toLower" call :_toLowerMyLib & goto _removeBatchVariablesMyLib +if /i "%_funcMyLib%"=="getTimestamp" call :_getTimestampMyLib & goto _removeBatchVariablesMyLib +if /i "%_funcMyLib%"=="logMessage" call :_logMessageMyLib & goto _removeBatchVariablesMyLib +if /i "%_funcMyLib%"=="padRight" call :_padRightMyLib & goto _removeBatchVariablesMyLib + +echo ERROR: Unknown function "%_funcMyLib%". Run "%~n0 /?" for usage. +goto _removeBatchVariablesMyLib + +:: ======================================================================== +:: LIBRARY FUNCTIONS +:: ======================================================================== + +:_trimWhitespaceMyLib + REM Trim leading and trailing spaces from a variable. + REM %_argOneMyLib% = name of the variable to trim (passed by name). + if not defined _argOneMyLib goto :eof + setlocal EnableDelayedExpansion + set "_valMyLib=!%_argOneMyLib%!" + REM Trim leading spaces. + for /f "tokens=* delims= " %%a in ("!_valMyLib!") do set "_valMyLib=%%a" + REM Trim trailing spaces. + :_trimTrailingMyLib + if "!_valMyLib:~-1!"==" " ( + set "_valMyLib=!_valMyLib:~0,-1!" + goto _trimTrailingMyLib + ) + endlocal & set "%_argOneMyLib%=%_valMyLib%" +goto :eof + +:_toLowerMyLib + REM Convert a variable's value to lowercase. + REM %_argOneMyLib% = name of the variable to convert (passed by name). + if not defined _argOneMyLib goto :eof + setlocal EnableDelayedExpansion + set "_valMyLib=!%_argOneMyLib%!" + set "_valMyLib=!_valMyLib:A=a!" + set "_valMyLib=!_valMyLib:B=b!" + set "_valMyLib=!_valMyLib:C=c!" + set "_valMyLib=!_valMyLib:D=d!" + set "_valMyLib=!_valMyLib:E=e!" + set "_valMyLib=!_valMyLib:F=f!" + set "_valMyLib=!_valMyLib:G=g!" + set "_valMyLib=!_valMyLib:H=h!" + set "_valMyLib=!_valMyLib:I=i!" + set "_valMyLib=!_valMyLib:J=j!" + set "_valMyLib=!_valMyLib:K=k!" + set "_valMyLib=!_valMyLib:L=l!" + set "_valMyLib=!_valMyLib:M=m!" + set "_valMyLib=!_valMyLib:N=n!" + set "_valMyLib=!_valMyLib:O=o!" + set "_valMyLib=!_valMyLib:P=p!" + set "_valMyLib=!_valMyLib:Q=q!" + set "_valMyLib=!_valMyLib:R=r!" + set "_valMyLib=!_valMyLib:S=s!" + set "_valMyLib=!_valMyLib:T=t!" + set "_valMyLib=!_valMyLib:U=u!" + set "_valMyLib=!_valMyLib:V=v!" + set "_valMyLib=!_valMyLib:W=w!" + set "_valMyLib=!_valMyLib:X=x!" + set "_valMyLib=!_valMyLib:Y=y!" + set "_valMyLib=!_valMyLib:Z=z!" + endlocal & set "%_argOneMyLib%=%_valMyLib%" +goto :eof + +:_getTimestampMyLib + REM Write a YYYY-MM-DD_HH-MM-SS timestamp into the named variable. + REM %_argOneMyLib% = name of the output variable. + REM NOTE: Uses %DATE% and %TIME% which are locale-dependent. The parsing + REM below assumes US-style format (e.g., "Fri 04/18/2026" or "04/18/2026"). + REM Adjust the substring offsets for your locale, or use PowerShell for + REM a locale-independent alternative: + REM for /f %%a in ('powershell -nop -c "Get-Date -F yyyy-MM-dd_HH-mm-ss"') do set "var=%%a" + if not defined _argOneMyLib goto :eof + setlocal EnableDelayedExpansion + REM Parse date — strip leading day name if present (e.g., "Fri "). + set "_dtMyLib=%DATE%" + if "!_dtMyLib:~3,1!"==" " set "_dtMyLib=!_dtMyLib:~4!" + set "_stampMyLib=!_dtMyLib:~6,4!-!_dtMyLib:~0,2!-!_dtMyLib:~3,2!" + REM Parse time — replace leading space with 0 for single-digit hours. + set "_tmMyLib=%TIME: =0%" + set "_stampMyLib=!_stampMyLib!_!_tmMyLib:~0,2!-!_tmMyLib:~3,2!-!_tmMyLib:~6,2!" + endlocal & set "%_argOneMyLib%=%_stampMyLib%" +goto :eof + +:_logMessageMyLib + REM Write a timestamped log line to stdout. + REM %_argOneMyLib% = level (INFO, WARN, ERROR) + REM %_argTwoMyLib% = message text + REM NOTE: Uses %DATE% and %TIME% (locale-dependent). See :_getTimestampMyLib. + setlocal EnableDelayedExpansion + set "_dtMyLib=%DATE%" + if "!_dtMyLib:~3,1!"==" " set "_dtMyLib=!_dtMyLib:~4!" + set "_tmMyLib=%TIME: =0%" + set "_tsMyLib=!_dtMyLib:~6,4!-!_dtMyLib:~0,2!-!_dtMyLib:~3,2! !_tmMyLib:~0,2!:!_tmMyLib:~3,2!:!_tmMyLib:~6,2!" + echo [!_tsMyLib!] [%_argOneMyLib%] %_argTwoMyLib% + endlocal +goto :eof + +:_padRightMyLib + REM Pad a string to a given width with trailing spaces. + REM %_argOneMyLib% = the string to pad + REM %_argTwoMyLib% = desired total width + if not defined _argOneMyLib goto :eof + if not defined _argTwoMyLib goto :eof + setlocal EnableDelayedExpansion + set "_valMyLib=%_argOneMyLib%" + set "_padMyLib=%_valMyLib% " + set "_padMyLib=!_padMyLib:~0,%_argTwoMyLib%!" + echo !_padMyLib! + endlocal +goto :eof + +:: ======================================================================== +:: HELP +:: ======================================================================== + +:_showHelpMyLib + echo: + for /f "skip=1 delims=" %%a in ('findstr /n "^" "%~f0"') do ( + set "_line=%%a" + setlocal EnableDelayedExpansion + for /f "delims=:" %%n in ("!_line!") do set "_lineNum=%%n" + if !_lineNum! GTR %_helpLinesMyLib% ( + endlocal + goto :eof + ) + set "_text=!_line:*:=!" + if defined _text ( + echo !_text:~4! + ) else ( + echo: + ) + endlocal + ) +goto :eof + +:: ======================================================================== +:: CLEANUP — Remove all batch variables. +:: ======================================================================== +:_removeBatchVariablesMyLib + set _helpLinesMyLib= + set _funcMyLib= + set _argOneMyLib= + set _argTwoMyLib= + set _argThreeMyLib= + set _valMyLib= + REM Append new variables above this line. + exit /b diff --git a/skills/batch-files/assets/task.txt b/skills/batch-files/assets/task.txt new file mode 100644 index 000000000..f5184277b --- /dev/null +++ b/skills/batch-files/assets/task.txt @@ -0,0 +1,177 @@ +@echo off +REM myTask +:: An automation script for scheduled or manual task execution. +:: +:: usage: myTask [options] +:: [1] = task target or configuration value (optional) +:: +:: options: +:: /? Show this help message +:: -h Show this help message +:: --help Show this help message +:: --dry Dry-run mode (preview actions without executing) +:: +:: examples: +:: > myTask +:: - Run the default task. +:: > myTask --dry +:: - Preview what the task would do without making changes. +:: > myTask "C:\data\reports" +:: - Run the task against a specific target directory. +:: +set "_helpLinesMyTask=20" + +:: ======================================================================== +:: TEMPLATE INSTRUCTIONS +:: 1. Find/Replace "myTask" with your task name (camelCase). +:: 2. Find/Replace "MyTask" with your task name (PascalCase). +:: 3. Update the help block above (lines 2-20) for your task. +:: 4. Implement your logic in :_runMyTask. +:: 5. Add any new variables to :_removeBatchVariablesMyTask. +:: ======================================================================== + +:: Config variables. +set "_dryRunMyTask=0" +set "_logFileMyTask=%TEMP%\%~n0.log" + +:: Define paths. +set "_scriptDirMyTask=%~dp0" +set "_scriptNameMyTask=%~n0" + +:: Parse arguments into variables. +set "_parOneMyTask=%~1" +set "_checkParOneMyTask=-%_parOneMyTask%-" +set "_parTwoMyTask=%~2" +set "_checkParTwoMyTask=-%_parTwoMyTask%-" + +:: ----------------------------------------------------------------------- +:: Handle help flag. +:: ----------------------------------------------------------------------- +if "%_parOneMyTask%"=="/?" call :_showHelpMyTask & goto _removeBatchVariablesMyTask +if /i "%_parOneMyTask%"=="-h" call :_showHelpMyTask & goto _removeBatchVariablesMyTask +if /i "%_parOneMyTask%"=="--help" call :_showHelpMyTask & goto _removeBatchVariablesMyTask + +:: ----------------------------------------------------------------------- +:: Handle --dry flag (shift arguments if present). +:: ----------------------------------------------------------------------- +if /i "%_parOneMyTask%"=="--dry" ( + set "_dryRunMyTask=1" + set "_parOneMyTask=%~2" + set "_checkParOneMyTask=-%~2-" +) + +:: Store current directory to return to after task completes. +set "_savedDirMyTask=%CD%" + +:: Create temp directory for intermediate files. +call :_makeTempDirMyTask + +:: ----------------------------------------------------------------------- +:: Log start and begin execution. +:: ----------------------------------------------------------------------- +call :_logMyTask "==========================================" +call :_logMyTask "Task started: %_scriptNameMyTask%" +call :_logMyTask "==========================================" + +call :_runMyTask + +call :_logMyTask "Task finished: %_scriptNameMyTask%" +goto _removeBatchVariablesMyTask + +:: ======================================================================== +:: MAIN LOGIC +:: ======================================================================== + +:_runMyTask + REM =================================================================== + REM TODO: Replace this section with your task logic. + REM =================================================================== + + if "%_dryRunMyTask%"=="1" ( + call :_logMyTask "[DRY RUN] Would process target: %_parOneMyTask%" + goto :eof + ) + + REM Example: Process files in a target directory. + if NOT "%_checkParOneMyTask%"=="--" ( + if NOT EXIST "%_parOneMyTask%" ( + call :_logMyTask "ERROR: Target not found: %_parOneMyTask%" + goto :eof + ) + call :_logMyTask "Processing target: %_parOneMyTask%" + REM Add task operations here. + ) else ( + call :_logMyTask "Running default task (no target specified)." + REM Add default task operations here. + ) + + call :_logMyTask "Task operations complete." +goto :eof + +:: ======================================================================== +:: SUPPORT FUNCTIONS +:: ======================================================================== + +:_logMyTask + REM Write a timestamped message to both console and log file. + setlocal EnableDelayedExpansion + for /f "tokens=2 delims==" %%a in ('wmic os get localdatetime /value') do ( + set "_dtMyTask=%%a" + ) + set "_tsMyTask=!_dtMyTask:~0,4!-!_dtMyTask:~4,2!-!_dtMyTask:~6,2! !_dtMyTask:~8,2!:!_dtMyTask:~10,2!:!_dtMyTask:~12,2!" + echo [!_tsMyTask!] %~1 + echo [!_tsMyTask!] %~1 >>"%_logFileMyTask%" + endlocal +goto :eof + +:_showHelpMyTask + echo: + for /f "skip=1 tokens=* delims=" %%a in ('findstr /n "^" "%~f0"') do ( + set "_line=%%a" + setlocal EnableDelayedExpansion + set "_lineNum=!_line:~0,2!" + if !_lineNum! GTR %_helpLinesMyTask% ( + endlocal + goto :eof + ) + set "_text=!_line:*:=!" + if defined _text ( + echo !_text:~4! + ) else ( + echo: + ) + endlocal + ) +goto :eof + +:_makeTempDirMyTask + set "_tmpDirMyTask=%TEMP%\%~n0" + if NOT EXIST "%_tmpDirMyTask%" ( + mkdir "%_tmpDirMyTask%" >nul 2>nul + ) +goto :eof + +:: ======================================================================== +:: CLEANUP - Remove all batch variables and restore directory. +:: ======================================================================== +:_removeBatchVariablesMyTask + set _helpLinesMyTask= + set _dryRunMyTask= + set _logFileMyTask= + set _scriptDirMyTask= + set _scriptNameMyTask= + set _parOneMyTask= + set _checkParOneMyTask= + set _parTwoMyTask= + set _checkParTwoMyTask= + REM Append new variables above this line. + + if EXIST "%_tmpDirMyTask%" rmdir /S /Q "%_tmpDirMyTask%" >nul 2>nul + set _tmpDirMyTask= + + REM Restore original directory. + if DEFINED _savedDirMyTask ( + cd /D "%_savedDirMyTask%" + set _savedDirMyTask= + ) + exit /b diff --git a/skills/batch-files/references/batch-files-and-functions.md b/skills/batch-files/references/batch-files-and-functions.md new file mode 100644 index 000000000..ff74d371e --- /dev/null +++ b/skills/batch-files/references/batch-files-and-functions.md @@ -0,0 +1,295 @@ +# 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: `filename-YYYY-MM-DD@HH-MM-SS.ext`. 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\\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\`, 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 with `FOR /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 expression` for integer math (Windows NT 4+): supports `()`, `* / %`, `+ -`, `<< >>`, `& ^ |`, assignment operators. Numeric literals: `0x` hex, `0b` binary, `0` octal — beware `08`/`09` are invalid octal. Limited to 16- or 32-bit integers depending on Windows version. `SET /P variable=prompt` (Windows 2000+) prompts for input; pressing Enter alone leaves variable unchanged. + +**NT SET Features** — String substitution: `%PATH:str1=str2%` replaces occurrences (case-insensitive in XP+). `str1` can begin with `*` to match from start. Substrings: `%PATH:~10,5%` extracts 5 chars at offset 10. Negative offsets: `%PATH:~-10%` last 10 chars, `%PATH:~0,-2%` all but last 2. + +**Dynamic Environment Variables** — Computed on each expansion, don't appear in `SET` output: `%CD%` (current directory), `%DATE%`, `%TIME%`, `%RANDOM%` (0–32767), `%ERRORLEVEL%`, `%CMDCMDLINE%`, `%CMDEXTVERSION%`, `%HIGHESTNUMANODENUMBER%`. Hidden dynamics (discovered via `SET ""`): `%=C:%` (current dir on C:), `%=ExitCode%` (hex last exit), `%=ExitCodeAscii%`, `%__APPDIR__%` (exe parent folder with trailing `\`), `%__CD__%` (current dir with trailing `\`). If user sets a dynamic variable name, it overrides the dynamic value; unsetting restores it. + +**Verify if Variables are Defined** — `IF DEFINED varname` (requires Command Extensions). Safer than `IF "%var%"==""` which fails on values with doublequotes or special chars. Hidden/dynamic variables (`DATE`, `CD`, `RANDOM`, etc.) report as defined via `IF DEFINED` but `SET varname` returns "not defined" unless explicitly set. Check if dynamic vs static: `SET Date >NUL 2>&1` — errorlevel 1 means still dynamic. Demo: `FOR %%A IN (COMSPEC __APPDIR__ CD DATE ERRORLEVEL RANDOM TIME) DO (IF DEFINED %%A (...))`. + +**Validate Variables** — Check string formats with `FINDSTR` or `FOR /F` delims tricks. Hexadecimal: `FOR /F "delims=0123456789AaBbCcDdEeFf" %%A IN ("%~1") DO ECHO NOT hex` or `SET /A "=0x%~1"`. Decimal: `ECHO.%~1| FINDSTR /R /X /C:"[0-9][0-9]*"`. IPv4: validate 4 dot-separated blocks 0–255 with nested checks (reject 256+, reject non-numeric, reject wrong block count). IPv6: remove interface part (`%%` and after), check no `:::`, count colon-separated blocks (8 without `::`, fewer with `::` allowed), validate each block as 1–4 hex digits. MAC: 6 groups of 2 hex digits separated by `:` or `-`. ISBN-13: checksum by alternating multiply by 1 and 3. Luhn algorithm: for credit cards, IMEI — double alternating digits, subtract 9 if >9, compare checksum. + +**Delayed Variable Expansion** — Variables expanded with `%var%` are resolved when the line is READ, not when executed. Inside `FOR` loops and code blocks `(...)`, this means `%var%` gets the value from before the block runs. Enable with `SETLOCAL ENABLEDELAYEDEXPANSION` or `CMD /V:ON`. Use `!var!` instead of `%var%` for execution-time expansion. Example: `SET LIST=` then `FOR %A IN (*) DO SET LIST=!LIST! %A` builds cumulative list. Layout note: `FOR %%A IN (...) DO (SET X=%X%%%A)` is identical to single-line form — both expand `%X%` before the loop runs. Bug exists in delayed expansion with certain edge cases. + +**Escape Characters** — Percent `%` escaped by doubling `%%` in batch files. Caret `^` escapes special chars in CMD.EXE: `^&`, `^<`, `^>`, `^|`, `^^`, `^(`, `^)`. Doublequoting also protects special chars but quotes are passed to commands. Exclamation marks (with delayed expansion): use `^^!` (double caret needed — single caret consumed in first pass, exclamation in second delayed-expansion pass). `FIND` escapes doublequotes by doubling: `""""`. `FINDSTR` regex escapes: `\\`, `\[`, `\]`, `\"`, `\.`, `\*`, `\?`. CALL adds extra caret escaping to arguments — always test when passing escaped strings to CALL. + +**Command Line Parameters** — `%0` is program name, `%1`–`%9` are arguments. `%10` is NOT the 10th arg — it's `%1` followed by `0`. Use `SHIFT` to rotate parameters (or `SHIFT /n` to shift from position n). NT features: `%*` = all args, `%~d1` drive, `%~p1` path, `%~n1` filename, `%~x1` extension, `%~f1` full path. `%CmdCmdLine%` = original CMD invocation. Delimiters: commas/semicolons replaced by spaces (unless in quotes), first `/` after command replaced by space, multiple spaces collapsed. Loop alternative: `FOR %%A IN (%*) DO (handle %%A)`. Validate with GOTO trick: `GOTO:%~1 2>NUL` / `IF ERRORLEVEL 1 (echo invalid)`. + +**Random Numbers** — `%RANDOM%` dynamic variable gives 0–32767 range. Techniques: (1) Native: `FOR /F "tokens=*" %%A IN ('VER ^| TIME ^| FINDSTR /R "[.,]"') DO FOR %%B IN (%%A) DO SET Random=%%B` (hundredths of seconds, not truly random in loops). (2) PowerShell: `FOR /F %%A IN ('powershell.exe -Command "Get-Random -Minimum 1 -Maximum 100"') DO SET Random=%%A`. (3) Rexx: `rexxtry say Random(min, max)`. (4) VBScript: `Randomize` then `WScript.Echo Int((6 * Rnd) + 1)`, capture with `FOR /F %%A IN ('CSCRIPT //NoLogo random.vbs') DO SET Random=%%A`. + +## String Processing + +**Get String Length** — No native string length function. Brute force: iterate character positions with `!var:~%%A,1!` until empty. Successive approximation (faster for long strings): binary search using `IF NOT "!var:~N!"==""` at powers of 2 (512, 256, 128, ..., 1), accumulating length. Example brute force: `SET len=0` / `FOR /L %%A IN (0,1,8191) DO IF NOT "!str:~%%A,1!"=="" SET /A len=%%A+1`. + +**FOR /F Tokens and Delims** — `FOR /F "tokens=n,m* delims=ccc" %%A IN ('command') DO ...`. Delimiters split input into tokens; multiple consecutive delimiters treated as one. Leading delimiters before first word are ignored (useful for stripping leading spaces: `FOR /F "tokens=*" %%A IN (" text") DO ECHO %%A`). First specified token maps to `%%A`, next to `%%B`, etc. `tokens=*` captures entire remainder. Escape pipe/redirect chars inside `FOR /F` parentheses with caret: `^|`, `^>`. No escaping needed when chars are inside quoted strings like `FIND "<03>"`. Strip leading zeroes: `FOR /F "tokens=* delims=0" %%A IN ("00012") DO ECHO %%A`. + +**String Substitution** — `%var:str1=str2%` replaces all occurrences of `str1` with `str2` in the variable value. Case-insensitive in XP+. `str2` can be empty to delete occurrences. `str1` can start with `*` to match everything from start to first occurrence of remainder. Example: `SET var=%var:old=new%`. + +**Substrings** — `%var:~offset,length%` extracts substring. Offset 0-based; negative offset counts from end. `%var:~-10%` last 10 chars. `%var:~0,-2%` all but last 2. Length omitted = rest of string. + +**Convert to Upper or Lower Case** — Method 1 (SET substitution with delayed expansion): `SET %~1=!%~1:a=A!` repeated for each letter A–Z. Call as subroutine: `CALL :UpCase VarName`. Method 2 (FOR loop, no delayed expansion needed): `FOR %%i IN ("a=A" "b=B" ...) DO CALL SET "%1=%%%1:%%~i%%"`. Title case variant replaces `" a= A"` (space-prefixed). Method 3 (Brad Thone): exploit case-insensitive substitution — `SET _Abet=A B C D...Z` then `FOR %%Z IN (%_Abet%) DO SET _Tmp=!_Tmp:%%Z=%%Z!`. Method 4 (FIND trick): `FIND` returns "file names" in upper case in "File not found" message — `FOR /F "tokens=2 delims=-" %%A IN ('FIND "" "%~1" 2^>^&1') DO SET UpCase=%%A` (XP+). Method 5 (DIR /L): `DIR /L /B ~%%B` converts temp filename to lowercase. PowerShell: `('%*').ToUpper()` or `('%*').ToLower()`. Warning: all SET-based methods vulnerable to code insertion — validate input first. + +**Align Text to Display as Tables** — Pad strings to fixed width: append N spaces then truncate: `SET Line=%%A%FortySpaces%` / `SET Line=!Line:~0,40!`. For dynamic column width, measure longest string first with brute-force length check (iterate positions 0..80, set width to max). Full pattern: `SET "EightySpaces=..."` / first pass `FOR /F` finds max length / second pass pads and appends second column. Console width detection: `FOR /F "tokens=2 delims=:" %%A IN ('MODE CON ^| FIND "Columns"') DO SET ConsoleWidth=%%A`. + +**Arrays in Batch Files** — Simulate arrays using variable naming conventions. `SET User` lists all vars starting with "User". Create array-like sets: `SET __Arr.Key1=Value1`, `SET __Arr.Key2=Value2`. Loop through: `FOR /F "tokens=2* delims=.=" %%A IN ('SET __Arr.') DO ECHO %%A = %%B`. WMIC example: `FOR /F "tokens=*" %%A IN ('WMIC LogicalDisk Where "DeviceID='C:'" Get /Format:list ^| FIND "="') DO SET __Disk.%%A`. Use `FINDSTR /R /C:"=."` to skip empty values (WMIC outputs CR/LF pairs in empty fields). Enumerate with `SET __Disk.` to list all stored properties. Closest approximation to associative arrays/hashtables in batch language. + +## Math and Arithmetic + +- **SET /A Arithmetic** — `SET /A` supports add (`+`), subtract (`-`), multiply (`*`), integer divide (`/`), modulo (`%%`), bit-shift (`<<`, `>>`), bitwise AND (`&`), OR (`|`), XOR (`^`), NOT (`~`), logical NOT (`!`), grouping `()`, and combined assignment operators (`+=`, `-=`, `*=`, `/=`, `%%=`, `&=`, `|=`, `^=`, `<<=`, `>>=`). Numeric literals: octal prefix `0`, hex prefix `0x`. 32-bit signed integer limit (−2,147,483,648 to 2,147,483,647); 16-bit on NT4. No exponentiation operator — use a loop multiplying in a variable. No square root — use binary search or PowerShell. +- **No Floating Point** — Batch has no native floating-point. Workaround: multiply by 100 (or 1000), do integer math, then extract whole and fraction parts via string slicing: `SET Whole=%Result:~0,-2%` and `SET Frac=%Result:~-2%`. For truly large or precise math, embed a PowerShell one-liner: `powershell -C "expression"`. +- **Big Number Workarounds** — For numbers exceeding 32-bit range: (1) chop last N digits for approximate math, (2) split into individual digits for arbitrary-precision add/multiply (e.g., process digit-by-digit with carry), (3) call PowerShell or another language. +- **Formatting Numbers** — Display hex: repeatedly divide by 16, index into `0123456789ABCDEF` helper string using `!Convert:~%Digit%,1!`. Display octal: divide by 8 loop. Right-align decimals: pad with spaces then chop with `!Align:~-8!`. File size limit ~107MB when multiplying by 20 (32-bit overflow). PowerShell `.ToString("format")` is simpler for complex formatting. +- **Boolean Logic in Conditions** — No AND/OR/XOR for `IF` conditions (only for binary math via `SET /A`). AND: nested `IF` statements. OR: set a temp variable to 0, set to 1 per matching condition, then test. XOR: too complex with nested IF. Better approach: assign each condition to a binary variable (0 or 1), then use `SET /A "ResultAND = %C1% & %C2%"`, `SET /A "ResultOR = %C1% | %C2%"`, `SET /A "ResultXOR = %C1% ^ %C2%"`. +- **Leading Zeroes Gotcha** — `SET /A` treats numbers with leading `0` as octal, so `SET /A x=08` and `SET /A x=09` cause "invalid number" errors. Always strip leading zeroes before arithmetic. Common techniques: use `FOR /F` tokenizing, string manipulation to remove leading zeroes, or `SET /A "1%var:~-2% - 100"` pattern to force decimal interpretation. + +## Devices and Hardware + +- **DOS/NT Device Names** — Valid logical devices: AUX, CON, PRN, COM1-4, LPT1-3, NUL. In NT, check if a name is a device: `DIR %1 2>NUL | FIND /I "Volume" >NUL` — no volume label means it is a device. In DOS, AUX/CON/PRN are shown with current date/time by DIR, so must be checked separately. +- **DEVCON** — Command-line Device Manager alternative from the Windows Driver Kit (WDK). Key commands: `classes` (list setup classes), `find`/`findall` (find devices, including disconnected), `hwids` (list hardware IDs), `driverfiles` (list driver files), `install`/`remove`/`enable`/`disable`/`restart`/`rescan`, `reboot`, `status`, `resources`, `update`, `dp_add`/`dp_delete`/`dp_enum` (OEM driver packages). Remote: `-m:\\machine`. Class filter: `=ClassName` (e.g., `=USB`, `=Printer`, `=DiskDrive`). Hardware ID: `@hwid`. Example: `DEVCON FindAll =USB` lists all USB devices including disconnected. + +## Elevated Privileges + +- **Check Elevation** — Multiple techniques: (1) `OPENFILES >NUL 2>&1` — fails if not elevated, but `OPENFILES` is 64-bit only and fails in 32-bit processes on 64-bit Windows. (2) `CACLS "%SYSTEMROOT%\system32\config\system"` — check errorlevel; works if CACLS is available. (3) Most reliable: `WHOAMI /Groups | FIND "12288" >NUL` — works correctly regardless of 32/64-bit process. Detect 32-bit process on 64-bit Windows: if `PROCESSOR_ARCHITEW6432` is set (equals AMD64), it is a 32-bit process in 64-bit OS. +- **Set Elevation (UAC Prompt)** — Create a temporary VBScript on-the-fly: `Set UAC = CreateObject("Shell.Application")` then `UAC.ShellExecute "%~snx0", "%*", "%~sdp0", "runas", 1`. This restarts the batch file with elevated privileges. Variables are lost on restart (new process), so test elevation first thing. PowerShell check: `[Security.Principal.WindowsPrincipal]([Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)`. + +## Files and Folders + +- **Rename Files** — `REN oldname newname` supports wildcards: `REN *.txt *.bak`. Undocumented: `REN file.txt *s` chops the filename after the last occurrence of the character. Use `FOR` loops for complex renaming: `FOR %%A IN (*.txt) DO REN "%%A" "%%~nA_backup%%~xA"`. Rename folders with `MOVE oldfolder newfolder`. +- **File Properties via FOR Modifiers** — `FOR %%A IN (file) DO` with modifiers: `%%~nA` (name), `%%~xA` (extension), `%%~snA` (short 8.3 name), `%%~aA` (attributes), `%%~dA` (drive), `%%~zA` (size bytes), `%%~tA` (date/time), `%%~dpA` (drive+path/parent), `%%~fA` (full qualified path), `%%~$PATH:A` (first PATH match). Modifiers are combinable: `%%~nxA` (name+ext), `%%~dpnxA` (full path), `%%~fsA` (full short path). +- **File and Product Versions** — `FILEVER /V filename` (from Support Tools) displays file/product version, description, company. Extract version with `FOR /F`: parse the `/V` output. Comparing dotted version strings: compare each segment numerically (string comparison of `1.10` vs `1.9` fails because `"10" < "9"` alphabetically). +- **START and File Associations** — `START "title" [/D path] [/I] [/MIN] [/MAX] [/WAIT] [/B] [/SEPARATE] [/SHARED] [priority] command [args]`. Priority classes: `/LOW`, `/NORMAL`, `/HIGH`, `/REALTIME`, `/ABOVENORMAL`, `/BELOWNORMAL`. File associations via `HKEY_CLASSES_ROOT`: parameters `%1` (file path), `%L` (long name), `%W` (working directory). `PATHEXT` controls which extensions are resolved without explicit extension. +- **Temporary Files** — Use `"%TEMP%.\tempfile"` (with trailing dot) for safe temp paths. Windows 2000 `%TEMP%` often contains spaces — always quote. `RUNAS` may change `%TEMP%` to a read-only location. Create unique temp names with `%RANDOM%` or `%TIME::=%`. +- **PDF Commands** — Get page count: ExifTool (`-PageCount`), GhostScript (`gswin32c -q -dNODISPLAY -c "(file) (r) file runpdfbegin pdfpagecount = quit"`), PDFtk (`pdftk file dump_data | FIND "NumberOfPages"`), or native: `TYPE file.pdf | FINDSTR /R /C:"/Type\s*/Page"` (approximate). Merge: GhostScript or `pdftk file1.pdf file2.pdf cat output merged.pdf`. Print: Acrobat Reader `/P` or `/T`, Foxit `/p`, GhostScript, or registered print command. +- **Check Folder Exists** — NT: `IF EXIST "folder\"` (trailing backslash). DOS: `IF EXIST folder\NUL`. More robust: `PUSHD "folder" && (POPD & ECHO exists) || ECHO not exists`. The `NUL` trick may fail with junctions/symlinks in NT. `FOR /D` can also match directories: `FOR /D %%A IN (folder) DO ECHO found`. +- **FOR /D and FOR /R** — `FOR /D %%A IN (pattern) DO command` matches directories. `FOR /R [path] %%A IN (pattern) DO command` walks directory trees recursively. Combine: `FOR /R "C:\" /D %%A IN (*) DO ECHO %%A` lists all subdirectories. +- **RD (RMDIR)** — `RD /S /Q directory` removes directory tree silently. `/S` removes all subdirectories and files. `/Q` suppresses confirmation. Returns errorlevel 2 if directory not found, 145 if directory not empty (when `/S` omitted). +- **Wildcards Quirks** — `*` matches any characters including none; `?` matches exactly one character. Quirks: wildcards after the 3rd character of the extension are ignored in some commands. Short 8.3 names can cause unexpected matches (a file with a long name may match via its short name). `DIR *~*.*` returns unpredictable results. `DEL *~*.*` is dangerous — may delete unexpected files due to short name matching. + +## Redirection and Encoding + +- **FOR /F (File/String/Command Parsing)** — `FOR /F "options" %%A IN (source) DO command`. Options: `tokens=` (column selection, e.g., `1,3*`), `delims=` (delimiter chars, default space/tab), `eol=` (comment char, default `;`), `skip=n` (skip first N lines), `usebackq` (changes quoting: back-quotes for commands, double-quotes for filenames, single-quotes for strings). Sources: filename, `"string"`, `` `command` `` (with `usebackq`), or `('command')`. Variable modifiers: `%%~fA` (full path), `%%~dpA` (drive+path), etc. +- **Tokens and Delims** — `tokens=1,3` extracts columns 1 and 3 into `%%A` and `%%B`. `tokens=2*` gets column 2 in `%%A` and remainder in `%%B`. `tokens=1-5` gets columns 1–5. Default delimiters: space and tab. `delims=,;` sets comma and semicolon. `delims=` (nothing) reads the entire line. `eol=` must be set to empty (or a char not in data) to avoid skipping lines starting with `;`. +- **Redirection** — `>` (overwrite stdout), `>>` (append stdout), `2>` (redirect stderr), `2>&1` (merge stderr into stdout), `1>&2` (stdout to stderr), `|` (pipe stdout). File handles: 0=stdin, 1=stdout, 2=stderr. Place redirection before the command for readability: `>file ECHO text`. Escape with caret: `ECHO text ^> not-redirected`. Space before `>` may get echoed as part of the text. +- **Streams and Redirection Explained** — Three standard streams: Standard Output (handle 1), Standard Error (handle 2), Console (CON). `2>&1` merges stderr into stdout for combined piping/capture. `>CON` bypasses file redirection and always writes to console. Console output from `CLS` and some commands cannot be redirected. Best practice: `command > logfile 2>&1` to capture both streams. Ambiguity: lines ending in `1` or `2` before `>` may be misinterpreted as handle numbers. +- **TEE Equivalent** — No native TEE in Windows. Workaround: pipe to a batch/PowerShell script that writes to both screen and file. Or use port of Unix TEE command. Simple batch approximation: use `FOR /F` to read command output, `ECHO` to screen and `>>file` simultaneously. +- **Detect File Encoding** — `FOR /F` loop aborts on ASCII 0 (null) characters present in Unicode files. Test: `FOR /F %%A IN (file) DO (ECHO ANSI&GOTO:EOF)` — if the loop completes without the ECHO executing, the file is Unicode (contains null bytes that break `FOR /F`). +- **ASCII vs. Unicode Conversion** — `TYPE` does not lock files (useful for copying logs in use). Unicode to ASCII: `TYPE unicode.txt > ascii.txt`. ASCII to Unicode: `CMD /U /C TYPE ascii.txt > unicode.txt`. Unicode BOM header: bytes `0xFF 0xFE`. Convert Unix linefeeds to Windows: `TYPE input.txt | MORE /E /P > output.txt`. +- **Base64 Encoding/Decoding** — `CERTUTIL.EXE -encode inputfile outputfile.b64` (encode to Base64). `CERTUTIL.EXE -decode inputfile.b64 outputfile` (decode from Base64). Output includes header/footer lines (`-----BEGIN CERTIFICATE-----` / `-----END CERTIFICATE-----`) that may need stripping with `FINDSTR /V "CERTIFICATE"`. +- **Hex Encoding/Decoding** — `CERTUTIL.EXE -encodehex inputfile outputfile [format]`. Formats: default (hex editor view with offsets and ASCII), `4` (hex only, no ASCII or offsets), `12` (single continuous hex line). Decode: `CERTUTIL.EXE -decodehex hexfile outputfile`. PowerShell alternatives: `[Convert]::ToHexString()` / `[Convert]::FromHexString()` (.NET 5+). +- **File Hashes** — `CERTUTIL.EXE -hashfile filename [algorithm]`. Algorithms: MD2, MD4, MD5, SHA1 (default), SHA256, SHA384, SHA512. Example: `CERTUTIL -hashfile myapp.exe SHA256`. Alternative: FCIV (File Checksum Integrity Verifier, unsupported Microsoft tool, MD5/SHA1 only). PowerShell: `Get-FileHash -Algorithm SHA256 filename`. + +## Internet and Networking + +- **Get Default Browser** — Manual: `START ms-settings:defaultapps`. Programmatic: read `HKCU\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice\ProgID` via `REG QUERY`, returns a value like `FirefoxHTML-308046B0AF4A39CB`. Then look up the executable: `REG QUERY "HKCR\\shell\open\command"` to get the browser path. Old techniques using `ASSOC .html` / `FTYPE` no longer work reliably in Windows 10+. +- **Auto-Download Prompt** — Check if a third-party tool exists: `TOOL /? >NUL 2>&1` then `IF ERRORLEVEL 1` means missing. If tool returns non-zero on `/?`, use `(TOOL /? 2>&1) | FIND /I "copyright" >NUL` to detect its output. Prompt user: `SET /P Download=Download now? [y/N]`, then `IF /I "%Download%"=="Y" START "title" "https://download-page"`. Always detect before executing to avoid cryptic `not recognized` errors. +- **E-mail from Batch** — `START mailto:user@example.com?subject=Hello%%20World^&body=Message%%20text`. Escaping: spaces=`%%20`, CR/LF=`%%0D%%0A`, ampersands escaped with caret (`^&`), double `%%` for batch. Length limited to max command line (~8191 chars on modern Windows). Only creates the message — user must press Send. For unattended sending: use third-party tools like Blat (SMTP, free) or MailSend (shareware). HTML5 also supports `` and ``. +- **FTP Scripting** — `FTP -s:scriptfile hostname` for unattended transfers. Script file contains: `USER username`, password (next line), `cd path`, `binary`, `prompt n`, `mget *.*` (or `mput`). Security: create script on-the-fly with `ECHO` redirection, delete after use (`TYPE NUL >script.ftp & DEL script.ftp`). Check for errors: redirect FTP output to log file, use `FIND` to search for error messages. Alternatives: WGET (`wget ftp://host/file` for anonymous downloads), WinSCP (SFTP/FTP with scripting interface), ScriptFTP (encrypted scripts, self-contained executables). +- **WMIC (WMI Command Line)** — Available XP Pro+ (disabled by default in Windows 11). Commands: `GET` (read properties), `SET` (change), `CALL` (invoke methods). Output formats: `/Format:csv`, `/Format:list`, `/Format:htable`. Store in variables: `FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturer^,Name /Value ^| FIND "="') DO SET BIOS.%%A`. `WHERE` clause with WQL: `WMIC Path Win32_NetworkAdapter Where "PhysicalAdapter=TRUE" Get`. Aliases vs full class path: `WMIC OS Get` = `WMIC Path Win32_OperatingSystem Get`. Remote: `/Node:computer`. Non-default namespace: `/NameSpace:\\root\other`. Registry access possible but `REG.EXE` is easier. +- **DMIDecode** — Linux/Unix utility ported to Windows for reading DMI/SMBIOS data (hardware info like BIOS, system, baseboard, chassis, processor details) directly from firmware tables without WMI. +- **RAS (Remote Access)** — Commands for managing dial-up and VPN connections from the command line. `RASDIAL entryname [username password]` to connect, `RASDIAL /DISCONNECT` to disconnect. `RASPHONE -h entryname` to hang up. +- **Terminal Server Commands** — `QUERY USER [/SERVER:name]` (list sessions), `QUERY SESSION`, `LOGOFF sessionid /SERVER:name`, `TSSHUTDN seconds /SERVER:name /POWERDOWN /DELAY:n /V` (shutdown with notification), `MSG sessionid message`, `SHADOW sessionid` (remote control). Use `CHANGE LOGON /DISABLE` to prevent new logons. + +## Login Scripts and Administration + +- **Network Drive Mapping** — `NET USE G: \\Server\Share /PERSISTENT:No` to map. `NET USE G: /DELETE` to disconnect. Group-based conditional mapping: `NET GROUP "groupname" /DOMAIN | FINDSTR /I "%USERNAME%"` then map if found. Always use `/PERSISTENT:No` in login scripts to prevent stale mappings. +- **Network Printer Mapping** — `NET USE LPT1 \\Server\Printer` to connect a printer port. For non-port-based printing, use `RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /n \\Server\Printer`. Set default printer: `WMIC Path Win32_Printer Where Name='PrinterName' Call SetDefaultPrinter`. +- **Log Computer Access** — Create date-based log folders and append login events: log `%COMPUTERNAME%`, `%USERNAME%`, date/time. Capture IP and MAC: `IPCONFIG /ALL` parsed with `FOR /F`, or `WMIC NIC Where NetEnabled=TRUE Get MACAddress`. Check antivirus status via WMI SecurityCenter namespace. +- **Login Script Best Practices** — Keep scripts lean; avoid bloating with unnecessary operations. Skip mapping when connections already exist. Do not map drives on servers. Use dedicated Terminal Server login scripts separate from regular workstation scripts. Test thoroughly across different Windows versions. +- **Active Directory Command-Line Tools (DS Tools)** — `DSQUERY` (find AD objects: `DSQUERY USER -name "John*"`), `DSGET` (read properties: `DSGET USER "CN=John,DC=corp,DC=com" -email`), `DSADD` (create objects), `DSMOD` (modify), `DSRM` (delete), `DSMOVE` (move/rename). All accept distinguished name (DN) format. Pipe results: `DSQUERY USER -inactive 12 | DSMOD USER -disabled yes`. + +## Printing + +- **Print Text Files** — Classic: `PRINT myfile.txt /D:LPT1` (requires LPT/COM port). Modern: `NOTEPAD /P file.txt` (default printer, any text file regardless of association). Wordpad: `WRITE /P file.rtf` (with print dialog) or `WRITE /PT file.rtf PrinterName` (silent, specific printer). +- **Print Registered File Types** — Technique: use `ASSOC .ext` to get the file type, then look up the print command in `HKCR\FileType\shell\print\command`. HTML: `RUNDLL32.EXE MSHTML.DLL,PrintHTML "%1"`. PDF: read association from registry, extract print command via `REGEDIT /E` or `REG QUERY`. For any registered type: query `HKCR\filetype\shell\print\command` and execute with `START /MIN`. File association parameters: `%1` (full path), `%L` (long name), `%W` (parent folder). +- **Command-Line Switches for Applications** — Extensive collection of print/open/convert switches: Adobe Reader (`/P` print dialog, `/N /T file printer` silent print), Foxit Reader (`/p` silent, `/t file printer`), IrfanView (`/print`, `/convert=output`), OpenOffice (`-pt "Printer" file`), Word (requires VBA macro `winword /mPrintDefault /q /n`), Notepad (`/P`), Wordpad (`/P`, `/PT`), PowerPoint (`/PT "Printer" "" "" "File"`). Most programs accept the file path as first argument to open it. +- **Command-Line Printer Control (PRINTUI.DLL)** — `RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry [options]` (Windows 7 shorthand: `PRINTUI.EXE [options]`). Install printer: `/if /b "Name" /f ntprint.inf /r "port:" /m "Model"`. Delete: `/dl /n "Name"`. Set default: `/y /n "Name"`. Get/set settings: `/Xg` / `/Xs`. Backup: `/Ss /n "printer" /a "file.dat"`. Restore: `/Sr /n "printer" /a "file.dat"`. Always returns errorlevel 0 — verify success by exporting settings to file and checking existence. Migrate printers: PrintMig 3.1 (W2K/XP/2003) or PRINTBRM (W7/2008+). +- **DDE Command-Line Control** — Programs that act as DDE servers can be controlled from the command line using DDE commands. Tools like CMCDDE and ClassExec send DDE execute/request commands to running applications. Useful for controlling Office apps that lack direct print commands. +- **Printer Management Scripts** — Windows ships with VBScript printer management scripts in `%windir%\System32\` (pattern `*prn*.vbs`): `prnmngr.vbs` (add/delete/list printers), `prncnfg.vbs` (configure), `prnport.vbs` (manage ports), `prndrvr.vbs` (manage drivers), `prnjobs.vbs` (manage print jobs). + +## Processes and Services + +- **Managing Processes** — Native (XP+): `TASKLIST` (list processes; `/V` verbose with window title, `/SVC` show hosted services, `/FI "filter"` filter by criteria like `IMAGENAME`, `PID`, `STATUS`, `USERNAME`, `MEMUSAGE`; output formats `/FO TABLE|LIST|CSV`). `TASKKILL /PID pid` or `/IM imagename` (kill by PID or name; `/F` force, `/T` tree kill including children). Resource Kit alternatives: `KILL pid|pattern`, `TLIST [-t]` (tree view), `PULIST` (process+user). SysInternals: `PSKILL [\\remote] pid|name`, `PSLIST [-d|-m|-x|-t|-s]`. Determine own PID: `FOR /F "tokens=2" %%A IN ('TASKLIST /V ^| FIND /I "%~0"') DO SET MyPID=%%A` (works because TASKLIST `/V` shows CMD window title which contains the batch file path). +- **Shutdown, Reboot, Logoff** — `SHUTDOWN /s /t 60 /c "message"` (shutdown in 60s with warning), `SHUTDOWN /p` (immediate), `SHUTDOWN /l` (logoff), `SHUTDOWN /r /t 0` (immediate reboot), `SHUTDOWN /h` (hibernate), `SHUTDOWN /a` (abort pending shutdown). WMIC: `WMIC OS Where Primary=TRUE Call Shutdown|Reboot|Win32Shutdown`. Win32Shutdown codes: 0=Logoff, 1=Shutdown, 2=Reboot, +4=Force, 8=Poweroff. Lock workstation: `RUNDLL32 USER32.DLL,LockWorkStation`. Sleep: `RUNDLL32 powrprof.dll,SetSuspendState Sleep`. PowerShell: `Restart-Computer [-Force]`, `Stop-Computer [-Force]`, `Stop-Computer -ComputerName "remote"`. SysInternals PSSHUTDOWN for remote machines. +- **SC (Service Controller)** — `SC \\computer [command] [service] [options]`. Commands: `query` (status), `start`, `stop`, `config` (change settings), `description`, `failure` (recovery actions), `delete`, `create`, `qc` (query config), `qdescription`, `qfailure`. Change startup: `SC Config servicename start= auto|disabled|demand`. Recovery: `SC Failure servicename actions= restart/60000/restart/60000// reset= 120` (restart after 1 min on first two failures, no action after). Important: space after `=` is mandatory (`start= auto`, not `start=auto`). Service names are the short name, not display name—find via `services.msc` or `SC Query`. + +## Program Flow + +- **Conditional Execution** — `IF condition command`. `IF ... ELSE` requires parentheses: `IF condition (cmd1) ELSE (cmd2)`. `IF ... ELSE IF` chains via: `IF cond1 (cmd1) ELSE IF cond2 (cmd2) ELSE (cmd3)`. Command chaining: `&` (always sequential), `&&` (execute next only on success/errorlevel 0), `||` (execute next only on failure/non-zero errorlevel). Combine: `(cmd1 && cmd2 && cmd3) || ECHO Error occurred`. Logical AND in conditions: nested `IF`. Logical OR: set temp variable per condition, test final value. +- **FOR Loops (DOS and NT)** — Basic: `FOR %%A IN (set) DO command`. `FOR /D %%A IN (pattern) DO` (directories only). `FOR /R [path] %%A IN (pattern) DO` (recursive tree walk). `FOR /L %%A IN (start,step,end) DO` (numeric range). `FOR /F "options" %%A IN (source) DO` (parse files/strings/commands). At command prompt use `%A`; in batch files use `%%A`. Variables are single-letter, case-sensitive (`%%A` ≠ `%%a`). +- **FOR /F Details** — `tokens=1,3*` extracts columns 1 and 3 into `%%A`/`%%B`, remainder into `%%C`. `delims=,;` sets delimiters. `eol=` (comment character). `skip=n` (skip header lines). `usebackq` enables back-quoted commands and double-quoted filenames. Variable modifiers: `%%~fA` (full path), `%%~dpA` (drive+path), `%%~nxA` (name+ext), `%%~zA` (file size), `%%~tA` (timestamp), `%%~aA` (attributes), `%%~$PATH:A` (search PATH). Modifiers are combinable. +- **File Attributes in FOR** — `%%~aA` expands to a string of attribute flags like `d--------` (directory) or `--a------` (archive). Attribute positions: `d` (directory), `r` (read-only), `a` (archive), `h` (hidden), `s` (system), plus compressed, encrypted, etc. Test with `IF "%%~aA" GEQ "d" ECHO directory` or parse specific character positions. +- **Extended FOR Variables** — Punctuation characters can serve as FOR variable names: `%%~f#`, `%%~dp$PATH:!`, etc. This allows nested FOR loops without running out of letter variables. Numbers as FOR variables: `%%0`–`%%9` and `%%~f0` etc. work in some contexts but conflict with batch parameters `%0`–`%9`. +- **Mimic While Loops** — Do...Until: `:Loop` / do work / `IF NOT condition GOTO Loop`. Do...While: `:Loop` / `IF condition GOTO End` / do work / `GOTO Loop` / `:End`. Use unique label names with numeric suffixes (`:Loop1`, `:Loop2`) to avoid conflicts. +- **GOTO** — `GOTO label` jumps to `:label`. `GOTO:EOF` exits the current subroutine (or batch file if not in a `CALL`ed subroutine). Labels are case-insensitive. Only the first 8 characters of a label are significant in some Windows versions. `GOTO` inside a parenthesized code block (like `FOR` or `IF`) breaks out of that block. +- **Continuous FOR /L Loops** — `FOR /L %%A IN (1,0,1) DO command` creates an infinite loop (step=0, never reaches end). Also: `FOR /L %%A IN () DO` or very large end values. Useful for polling/waiting scenarios. +- **Breaking Endless Loops** — `Ctrl+C` sends break signal. From another process: `TASKKILL /F /IM cmd.exe /FI "WINDOWTITLE eq BatchTitle"`. Self-breaking: check a flag file or registry value each iteration, `IF EXIST stop.flag GOTO End`. +- **Errorlevels** — `IF ERRORLEVEL n` is TRUE if errorlevel >= n (not equal!). Exact test: `IF %ERRORLEVEL% EQU 0` (or `NEQ`, `GTR`, `LSS`). Never create a variable named `ERRORLEVEL` (shadows the dynamic pseudo-variable). Set errorlevel: `EXIT /B n` (W2K+, exits batch/subroutine and sets errorlevel to n). Reset to 0: `CMD /C EXIT 0` or `VER >NUL`. Force non-zero: `COLOR 00` (sets errorlevel 1) or `VERIFY OTHER 2>NUL` (sets errorlevel 1). For exact errorlevel checking in DOS: reverse-order `IF ERRORLEVEL` chain (check highest first). +- **EXIT** — `EXIT` closes the CMD window entirely. `EXIT /B [exitcode]` exits only the current batch file (or subroutine if called via `CALL`) and optionally sets `%ERRORLEVEL%` to exitcode. Always use `EXIT /B` in batch files to avoid closing the user's terminal. In subroutines: `EXIT /B 0` for success, `EXIT /B 1` (or other non-zero) for failure. + +## Registry + +- **REGEDIT** — GUI and command-line registry editor. Import (merge): `REGEDIT /S importfile.REG` (silent). Export: `REGEDIT /E exportfile.REG "HKEY_XXXX\Whatever Key"`. Remove tree via .REG file: prefix key with minus `[-HKEY_CURRENT_USER\DummyTree]`. Remove single value: `"ValueToBeRemoved"=-`. Self-contained .REG batch hybrid: start file with `REGEDIT4`, use semicolons for batch commands (`;@ECHO OFF` / `;REGEDIT.EXE /S "%~f0"` / `;EXIT`), then registry entries below. Warning: always back up registry before editing. +- **REG.EXE** — Command-line registry tool (Resource Kit for NT4, native since XP). Read values with `FOR /F`: `FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKCU\Control Panel\International" /v sCountry') DO SET Country=%%B`. Use `tokens=2*` with asterisk to capture multi-word values. Subcommands: `REG QUERY`, `REG ADD`, `REG DELETE`, `REG COPY`, `REG EXPORT`, `REG IMPORT`. Combine with `FOR /F` to extract any registry value into environment variables. +- **WMIC Registry** — Check registry access permissions: `WMIC /NameSpace:\\root\default Class StdRegProv Call CheckAccess`. Also query registry values programmatically through WMI's `StdRegProv` class methods like `GetStringValue`, `EnumKey`, `EnumValues`. +- **Search the Registry** — Windows 7+ `REG Query` supports `/F` (Find) switch: `REG Query HKLM\Software /F "searchpattern" /S`. Use `/K` to search key names only (fast), `/V` for value names (fast), `/D` for data (slow), or omit for all. Use `/E` for exact matches, `/C` for case-sensitive. Example: `REG Query HKLM\Software /V /F AppPath /S /E` finds all values named exactly "AppPath". + +## Date and Time + +- **DATE and TIME Basics in NT** — Get current date/time: `FOR /F "tokens=*" %%A IN ('DATE /T') DO SET Today=%%A` or use built-in `%Date%` and `%Time%` variables (W2K+). Inner `FOR` loop strips day-of-week prefix. Values are locale-dependent (order of day/month, separators, AM/PM vs 24h all depend on regional settings). +- **Parsing DATE and TIME** — Two approaches: `FOR /F` with delimiters (`FOR /F "tokens=1-3 delims=/-" %%A IN ("%Today%") DO ...`) or `SET` substring (`SET Year=%Today:~-4%`, `SET Month=%Today:~-10,2%`). Determine date order via registry: read `iDate` (0=MDY, 1=DMY, 2=YMD) and `sDate` (separator) from `HKCU\Control Panel\International` using `REG QUERY`. Parse time with leading zeros: `SET Now=%Time: =0%` then `SET Hours=%Now:~0,2%`. Strip leading zeros: `SET /A Hours = 100%Hours% %% 100`. +- **Advanced Date Math** — Convert dates to Julian day numbers for arithmetic. Fliegel-Van Flandern algorithm in batch (by Ron Bakowski): `:JDate` subroutine takes YYYY MM DD, returns Julian date. `:GDate` converts back. Date arithmetic: `SET /A JPast = JDate - 28` gives date 4 weeks ago. Weekday from Julian: `SET /A WD = %JDate% %% 7` (0=Monday...6=Sunday). Age in days: subtract birth Julian from today's Julian. +- **Read the CMOS Real Time Clock** — Use DEBUG to read CMOS RTC registers directly (16-bit only, requires 32-bit OS). Port `70` selects register, port `71` reads value. Registers: `09`=year, `08`=month, `07`=day, `04`=hours, `02`=minutes, `00`=seconds (all BCD). Register `0E` > `7F` means clock not set. 100% locale-independent but requires admin privileges. +- **Delays and Wait Techniques** — `PAUSE` waits for any key. `SLEEP n` (Resource Kit) waits n seconds. `TIMEOUT /T n` (native W7+) waits n seconds or keypress; `/NOBREAK` requires Ctrl+C. PING trick: `PING localhost -n 6 >NUL` delays ~5 seconds (n=seconds+1). CHOICE trick: `REM | CHOICE /C:AB /T:A,10 >NUL` (DOS) or `CHOICE /C:AB /D:A /T:10 >NUL` (W10). PowerShell: `powershell -Command "Start-Sleep -Seconds %1"`. +- **The AT Command** — Schedule commands at absolute times (NT Server): `AT [\\computername] time [/INTERACTIVE] [/EVERY:day,...] command`. Uses SYSTEM account by default. Batch files must be preceded with `CMD /C`. Debug scheduled tasks: schedule `CMD.EXE` with `/INTERACTIVE` to get a visible prompt in the SYSTEM context. Superseded by SCHTASKS in Windows XP+. +- **JT (Job Tool)** — Windows 2000 Resource Kit tool for Task Scheduler command line management. Enumerate tasks: `JT /SE` or `JT /SE P` for full details. Add, edit, or remove scheduled jobs on local/remote computers. Command line switches are unintuitive; use JTHelp.bat to generate HTML help. +- **SCHTASKS** — Full-featured task scheduler CLI (XP+). Subcommands: `/Create` (schedule new task), `/Delete`, `/Query`, `/Change`, `/Run` (run immediately), `/End` (stop running task), `/ShowSid`. Create example: `SCHTASKS /Create /SC DAILY /TN "MyTask" /TR "C:\script.bat" /ST 21:00`. Schedule types: MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT. Use `/RU` for run-as account, `/XML` for import/export, `/F` to force overwrite. + +## User Interaction + +- **User Input** — `SET /P variable=prompt` (W2K+) reads a line of user input. Warning: input containing `&`, `<`, `>`, `|` or `"` can cause code injection—never use `SET /P` in elevated scripts. NT4: `FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A` (user presses F6+Enter to finish). MS-DOS: `CHOICE /C:YN` for single-key Yes/No. PowerShell login dialog: `FOR /F "tokens=1* delims=;" %%A IN ('PowerShell ./login.ps1 %UserName%') DO (SET Usr=%%A & SET Pwd=%%B)`. +- **Neat Dialog Boxes in Batch Files** — C# GUI utilities for batch: `MessageBox.exe` (popup message, returns clicked button caption), `InputBox.exe` (text input with optional password masking, regex filtering, timeout), `OpenFileBox.exe` / `SaveFileBox.exe` (file dialogs), `OpenFolderBox.exe` (folder browser), `PrinterSelectBox.exe`, `DateTimeBox.exe`, `DropDownBox.exe` / `RadioButtonBox.exe` (list selection), `MultipleChoiceBox.exe` (checkboxes), `ColorSelectBox.exe`, `FontSelectBox.exe`, `ProgressBarGUI.exe`. All write selection to stdout for `FOR /F` capture. Return errorlevel 0=OK, 2=Cancel. +- **Hide or Minimize the Console** — Start minimized: `START /MIN "title" "batch.bat"`. Minimize own window: `CONSOLESTATE /Min` or `SETCONSOLE /minimize` or title+CMDOW combo. Hide own window: `CONSOLESTATE /Hide` or `SETCONSOLE /hide`. Completely hidden (no flash): launch via `RUNNHIDE.EXE batch.bat` or `WSCRIPT.EXE RunNHide.vbs batch.bat` or `HSTART /NOCONSOLE "batch.bat"`. Note: hiding from within the batch always shows a brief console flash; cloaking must start before the batch. +- **Error Messages in Local Language** — `NET HELPMSG nnnn` displays Windows error message number nnnn in the local system language. Generate a complete list: `FOR /L %%A IN (0,1,16384) DO (FOR /F "tokens=*" %%B IN ('NET HELPMSG %%A 2^>NUL') DO ECHO %%A %%B)`. Use these numbers in batch scripts for localized error output without hardcoding translations. +- **Popup Messages** — `MSG.EXE` (XP Pro+): send popup to users/sessions. VBScript on-the-fly: `> msg.vbs ECHO WScript.Echo "message"` then `WSCRIPT msg.vbs`. MSHTA one-liner: `MSHTA vbscript:Close(MsgBox("message",vbOKOnly,"title"))`. PowerShell one-liner: `FOR /F "usebackq" %%A IN (\`PowerShell -Command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('message','title','YesNo','Question')"\`) DO SET Answer=%%A`. Result is button caption string (Yes, No, OK, Cancel). +- **ANSI Colors and Escape Sequences** — ANSI.SYS required in DOS; built into Windows 10+ CMD.EXE natively. Escape character = ASCII 27. Insert in batch via FORFILES: `FORFILES /P %~dps0 /M %~nxs0 /C "CMD /C ECHO 0x1B[1;31m Red Text 0x1B[0m"`. Color codes: `[30m`–`[37m` foreground, `[40m`–`[47m` background, `[1;3Xm` bright. Attributes: `[0m` reset, `[1m` bold, `[4m` underline, `[7m` reverse. Cursor: `[r;cH` position, `[nA/B/C/D` move, `[2J` clear screen, `[K` clear to end of line. In PROMPT strings use `$E` instead of the Esc character. + +## Miscellaneous and Collections + +- **UNIX Ports (WHICH, TEE, CUT)** — Batch/Rexx/Perl/PowerShell/VBScript ports of essential Unix utilities. WHICH: locate executables in PATH (handles DOSKEY macros and CMD internals). TEE: split stdout to both screen and file simultaneously. CUT: extract columns/fields from text. Also includes TRUE/FALSE utilities for explicit errorlevel setting. Available as native batch (.bat), compiled Perl (.exe), and multiple scripting language versions. +- **Undocumented NT Commands** — `ACINIUPD` (W2K Server): update INI files from command line (`ACINIUPD /e "file.ini" "section" key "value"`; `/u` for user directory; admin-only). `SFC /SCANNOW`: scan and replace corrupted protected system files. `TSSHUTDN` (Terminal Server): controlled server shutdown with user notification, reboot, and powerdown options. +- **DEBUG** — 16-bit DOS debugger repurposed for batch scripting (32-bit OS only; unavailable on 64-bit). Read CMOS Real Time Clock (locale-independent date/time). Read VideoROM manufacturer info. Read I/O port addresses for COM/LPT ports. Check CapsLock/NumLock/ScrollLock status. Create tiny .COM utilities (e.g., REPLY.COM for user input, RESET.COM for reboot). Embed scripts in batch: `DEBUG < %0.BAT` / `GOTO Around` / script / `:Around`. +- **Clever Tips and Tricks** — CMD /C quoting quirk: `CMD /C @"command" "arg"` (prefix `@` to prevent misparse when first and last chars are quotes). Elevation check: `WHOAMI /GROUPS | FIND "12288"` (works in both 32-bit and 64-bit). `PUSHD "%~dp0"` auto-maps UNC paths to drive letters (works with RUNAS, PSEXEC, UAC). `SET /P var= log.txt`. +- **ANSI Art and Console Colors** — Use ANSI escape sequences to create colored text screens and animations. ANSI.SYS (DOS) or Windows 10 built-in support. FORFILES technique generates Esc characters on-the-fly. Alternatives: `KOLOR.EXE` (set color for text selection in 32/64-bit), BG by Carlos M. (modern BATCHMAN replacement), EKKO by Norman De Forest (ECHO enhancement with PROMPT-like color functions without ANSI driver). +- **AUTOEXEC.BAT** — Automatic startup batch file executed by COMMAND.COM on boot (MS-DOS/Windows 9x). Used to set PATH, load TSRs, configure environment variables, and initialize devices. Not used in Windows NT+ (replaced by registry Run keys and startup folders). +- **PHP-Based Batch Files** — Technique for mixing PHP code with batch files. PHP CLI processes the script while batch commands are hidden in PHP comments. Useful for leveraging PHP string functions, regex, and web capabilities from within a .bat wrapper. +- **Batch HowTos and Sample Collections** — Curated collections of batch file techniques, how-to guides, and example scripts covering common Windows administration tasks. Topics include inventory scripts, login scripts, admin tools, network administration, and community-contributed solutions. "Poor Man's Admin Tools" provides lightweight batch-only alternatives to commercial utilities (PMChoice, PMSleep, PMSoon, and others). +- **Useful NT Commands for Administrators** — Reference of NT commands commonly used in administration batch scripts, including NET commands, SC (service control), TASKLIST/TASKKILL, WMIC, REG, SCHTASKS, ROBOCOPY, ICACLS, and system information utilities. diff --git a/skills/batch-files/references/cygwin.md b/skills/batch-files/references/cygwin.md new file mode 100644 index 000000000..1369cd92a --- /dev/null +++ b/skills/batch-files/references/cygwin.md @@ -0,0 +1,101 @@ +# Cygwin Reference + +Cygwin provides a large collection of GNU and Open Source tools that provide functionality similar to a Linux distribution on Windows, plus a POSIX API DLL (`cygwin1.dll`) for substantial Linux API compatibility. + +## Documentation + +- [Cygwin User's Guide](https://cygwin.com/cygwin-ug-net.html) — comprehensive official documentation +- [Cygwin FAQ](https://cygwin.com/faq.html) +- [Cygwin Homepage](https://cygwin.com/) + +## User's Guide — Table of Contents + +### Chapter 1: Cygwin Overview + +- **What is it?** — POSIX compatibility layer and GNU toolset for Windows +- **Quick Start Guide (Windows users)** — Getting started for those familiar with Windows +- **Quick Start Guide (UNIX users)** — Getting started for those familiar with UNIX/Linux +- **Are the Cygwin tools free software?** — Licensing (GPL/LGPL) +- **A brief history of the Cygwin project** — Origins and evolution +- **Highlights of Cygwin Functionality** + - Permissions and Security + - File Access + - Text Mode vs. Binary Mode + - ANSI C Library + - Process Creation + - Signals + - Sockets and Select +- **What's new and what changed** — Release notes for all versions (1.7.x through 3.6) + +### Chapter 2: Setting Up Cygwin + +- **Internet Setup** — Installing via `setup-x86_64.exe`, mirror selection, package management +- **Environment Variables** — Configuring `PATH`, `HOME`, `CYGWIN` and other environment variables +- **Changing Cygwin's Maximum Memory** — Adjusting memory limits via the registry +- **Internationalization** — Locale and character set configuration +- **Customizing bash** — `.bashrc`, `.bash_profile`, and prompt customization + +### Chapter 3: Using Cygwin + +- **Mapping path names** — How Cygwin maps POSIX paths to Windows paths (`/cygdrive/c` = `C:\`) +- **Text and Binary modes** — Line ending handling (`\n` vs `\r\n`), mount options +- **File permissions** — POSIX permission model on NTFS, ACLs +- **Special filenames** — Device files, `/proc`, `/dev`, socket files +- **POSIX accounts, permission, and security** — User/group mapping, `passwd`/`group` files, `ntsec` +- **Cygserver** — Background service for shared memory, message queues, semaphores +- **Cygwin Utilities** — Built-in command-line tools: + - `cygcheck` — System information and package diagnostics + - `cygpath` — Convert between POSIX and Windows paths + - `cygstart` — Open files/URLs with associated Windows applications + - `dumper` — Create Windows minidumps + - `getconf` — Query POSIX system configuration + - `getfacl` / `setfacl` — Get/set file access control lists + - `ldd` — List shared library dependencies + - `locale` — Display locale information + - `minidumper` — Write a minidump of a running process + - `mkgroup` / `mkpasswd` — Generate group/passwd entries from Windows accounts + - `mount` / `umount` — Manage Cygwin mount table + - `passwd` — Change passwords + - `pldd` — List loaded DLLs for a process + - `profiler` — Profile Cygwin programs + - `ps` — List running processes + - `regtool` — Access the Windows registry from the shell + - `setmetamode` — Control meta key behavior in the console + - `ssp` — Single-step profiler + - `strace` — Trace system calls and signals + - `tzset` — Print POSIX-compatible timezone string +- **Case-sensitive directories** — Enabling per-directory case sensitivity on Windows 10+ +- **Using Cygwin effectively with Windows** — Integration tips, running Windows programs from Cygwin + +### Chapter 4: Programming with Cygwin + +- **Using GCC with Cygwin** — Compiling C/C++ programs with the Cygwin GCC toolchain +- **Debugging Cygwin Programs** — Using GDB and other debugging tools +- **Building and Using DLLs** — Creating shared libraries under Cygwin +- **Defining Windows Resources** — Resource files and `windres` +- **Profiling Cygwin Programs** — Performance profiling with `gprof` and `ssp` + +## Key Concepts for Batch Scripting + +### Invoking Cygwin from Batch Files + +```batch +REM Run a Cygwin command from a batch file +C:\cygwin64\bin\bash.exe -l -c "ls -la /home" + +REM Convert a Windows path to POSIX for Cygwin +C:\cygwin64\bin\cygpath.exe -u "C:\Users\John Doe\Documents" + +REM Convert a POSIX path back to Windows +C:\cygwin64\bin\cygpath.exe -w "/home/jdoe/project" +``` + +### Common Environment Variables + +| Variable | Purpose | +|----------|---------| +| `CYGWIN` | Runtime options (e.g., `nodosfilewarning`, `winsymlinks:nativestrict`) | +| `HOME` | User home directory | +| `PATH` | Must include `/usr/local/bin:/usr/bin` for Cygwin tools | +| `SHELL` | Default shell (typically `/bin/bash`) | +| `TERM` | Terminal type for console applications | diff --git a/skills/batch-files/references/msys2.md b/skills/batch-files/references/msys2.md new file mode 100644 index 000000000..a117efe5b --- /dev/null +++ b/skills/batch-files/references/msys2.md @@ -0,0 +1,95 @@ +# MSYS2 Reference + +MSYS2 provides a collection of tools and libraries for building, installing, and running native Windows software. It uses Pacman (from Arch Linux) for package management. + +## Getting Started + +- [Getting Started](https://www.msys2.org/) +- [What is MSYS2?](https://www.msys2.org/docs/what-is-msys2/) +- [Who Is Using MSYS2?](https://www.msys2.org/docs/who-is-using-msys2/) +- [MSYS2 Installer](https://www.msys2.org/docs/installer/) +- [News](https://www.msys2.org/news/) +- [FAQ](https://www.msys2.org/docs/faq/) +- [Supported Windows Versions and Hardware](https://www.msys2.org/docs/windows_support/) +- [ARM64 Support](https://www.msys2.org/docs/arm64/) + +## Environments + +MSYS2 provides multiple environments targeting different use cases: + +- [Environments Overview](https://www.msys2.org/docs/environments/) +- [GCC vs LLVM/Clang](https://www.msys2.org/docs/environments/#gcc-vs-llvmclang) +- [MSVCRT vs UCRT](https://www.msys2.org/docs/environments/#msvcrt-vs-ucrt) +- [Changelog](https://www.msys2.org/docs/environments/#changelog) + +| Environment | Prefix | Toolchain | C Runtime | +|-------------|--------|-----------|-----------| +| MSYS | `/usr` | GCC | cygwin | +| MINGW64 | `/mingw64` | GCC | MSVCRT | +| UCRT64 | `/ucrt64` | GCC | UCRT | +| CLANG64 | `/clang64` | LLVM | UCRT | +| CLANGARM64 | `/clangarm64` | LLVM | UCRT | + +## Configuration + +- [Updating MSYS2](https://www.msys2.org/docs/updating/) +- [Filesystem Paths](https://www.msys2.org/docs/filesystem-paths/) +- [Symlinks](https://www.msys2.org/docs/symlinks/) +- [Configuration Locations](https://www.msys2.org/docs/configuration/) +- [Terminals](https://www.msys2.org/docs/terminals/) +- [IDEs and Text Editors](https://www.msys2.org/docs/ides-editors/) +- [Just-in-time Debugging](https://www.msys2.org/docs/jit-debugging/) + +## Package Management + +- [Package Management](https://www.msys2.org/docs/package-management/) +- [Package Naming](https://www.msys2.org/docs/package-naming/) +- [Package Index](https://packages.msys2.org/) +- [Repositories and Mirrors](https://www.msys2.org/docs/repos-mirrors/) +- [Package Mirrors](https://www.msys2.org/docs/mirrors/) +- [Tips and Tricks](https://www.msys2.org/docs/package-management-tips/) +- [FAQ](https://www.msys2.org/docs/package-management-faq/) +- [pacman](https://www.msys2.org/docs/pacman/) + +## Development Tools + +- [Using CMake in MSYS2](https://www.msys2.org/docs/cmake/) +- [Autotools](https://www.msys2.org/docs/autotools/) +- [Python](https://www.msys2.org/docs/python/) +- [Git](https://www.msys2.org/docs/git/) +- [C/C++](https://www.msys2.org/docs/c/) +- [C++](https://www.msys2.org/docs/cpp/) +- [pkg-config](https://www.msys2.org/docs/pkgconfig/) +- [Using MSYS2 in CI](https://www.msys2.org/docs/ci/) + +## Package Development + +- [Creating a new Package](https://www.msys2.org/dev/new-package/) +- [Updating an existing Package](https://www.msys2.org/dev/update-package/) +- [Package Guidelines](https://www.msys2.org/dev/package-guidelines/) +- [License Metadata](https://www.msys2.org/dev/package-licensing/) +- [PKGBUILD](https://www.msys2.org/dev/pkgbuild/) +- [Mirrors](https://www.msys2.org/dev/mirrors/) +- [MSYS2 Keyring](https://www.msys2.org/dev/keyring/) +- [Python](https://www.msys2.org/dev/python/) +- [Automated Build Process](https://www.msys2.org/dev/build-process/) +- [Vulnerability Reporting](https://www.msys2.org/dev/vulnerabilities/) +- [Accounts and Ownership](https://www.msys2.org/dev/accounts/) + +## Wiki + +- [Welcome to the MSYS2 wiki](https://www.msys2.org/wiki/Home/) +- [How does MSYS2 differ from Cygwin?](https://www.msys2.org/wiki/How-does-MSYS2-differ-from-Cygwin/) +- [MSYS2-Introduction](https://www.msys2.org/wiki/MSYS2-introduction/) +- [MSYS2 History](https://www.msys2.org/wiki/History/) +- [Creating Packages](https://www.msys2.org/wiki/Creating-Packages/) +- [Distributing](https://www.msys2.org/wiki/Distributing/) +- [Launchers](https://www.msys2.org/wiki/Launchers/) +- [Porting](https://www.msys2.org/wiki/Porting/) +- [Re-installing MSYS2](https://www.msys2.org/wiki/MSYS2-reinstallation/) +- [Setting up SSHd](https://www.msys2.org/wiki/Setting-up-SSHd/) +- [Signing Packages](https://www.msys2.org/wiki/Signing-packages/) +- [Do you need Sudo?](https://www.msys2.org/wiki/Sudo/) +- [Terminals](https://www.msys2.org/wiki/Terminals/) +- [Qt Creator](https://www.msys2.org/wiki/GDB-qtcreator/) +- [TODO LIST](https://www.msys2.org/wiki/Devtopics/) diff --git a/skills/batch-files/references/tools-and-resources.md b/skills/batch-files/references/tools-and-resources.md new file mode 100644 index 000000000..3a0fd67a2 --- /dev/null +++ b/skills/batch-files/references/tools-and-resources.md @@ -0,0 +1,125 @@ +# Windows Tools and Resources + +## Updates and News + +- [Terminal, Command Line and console blog](https://devblogs.microsoft.com/commandline/) +- [Rob van der Woude.com](https://www.robvanderwoude.com/batchfiles.php) +- [Security Bulletins](https://msrc.microsoft.com/update-guide) +- [OpenCVE](https://app.opencve.io/cve/?q=vendor%3Amicrosoft+AND+cvss31%3E%3D9) +- [Old New Thing](https://devblogs.microsoft.com/oldnewthing/tag/tipssupport) +- [Microsoft Update Catalog](https://www.catalog.update.microsoft.com/Home.aspx) +- [aka.ms Search](https://akasearch.net/) + +## Tools and Utilities + +- [Windows versions](https://ss64.com/nt/ver.html) +- [RSAT](https://ss64.com/links/ps.html#kits) +- [Domain Services Tools](https://docs.microsoft.com/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/cc771131(v=ws.11)) +- [RSAT Download](https://www.microsoft.com/download/details.aspx?id=45520) +- [RSAT KBase](https://docs.microsoft.com/troubleshoot/windows-server/system-management-components/remote-server-administration-tools) +- [DISM /Add-Capability](https://ss64.com/nt/dism.html) +- [Microsoft Security Compliance Toolkit](https://www.microsoft.com/download/details.aspx?id=55319) +- [Security Toolkit Release notes (2020)](https://techcommunity.microsoft.com/t5/microsoft-security-baselines/new-amp-updated-security-tools/ba-p/1631613) +- [Policy Analyzer Release notes](https://techcommunity.microsoft.com/t5/microsoft-security-baselines/new-tool-policy-analyzer/ba-p/701049) +- [Microsoft PowerToys](https://docs.microsoft.com/windows/powertoys/) +- [File Locksmith](https://learn.microsoft.com/windows/powertoys/file-locksmith) +- [Keyboard Manager](https://learn.microsoft.com/en-us/windows/powertoys/keyboard-manager) +- [PowerToys Releases (Github)](https://github.com/microsoft/PowerToys/releases) +- [ColorTool.exe](https://github.com/Microsoft/Terminal/tree/main/src/tools/ColorTool) +- [IE 11 Enterprise Mode Site List Manager](https://www.microsoft.com/download/details.aspx?id=49974) +- [Local Administrator Password Solution (LAPS)](https://www.microsoft.com/download/details.aspx?id=46899) +- [LAPS howto](https://learn-powershell.net/2016/10/08/setting-up-local-administrator-password-solution-laps/) +- [Sysinternals Suite](https://docs.microsoft.com/sysinternals/downloads/sysinternals-suite) +- [Account Lockout Status](https://www.microsoft.com/download/details.aspx?id=15201) +- [Account Lockout and Management Tools](https://www.microsoft.com/download/details.aspx?id=18465) +- [Microsoft Security Compliance Toolkit 1.0](https://www.microsoft.com/download/details.aspx?id=55319) +- [How to disable SMB 1 (or 2/3 for testing)](https://docs.microsoft.com/windows-server/storage/file-server/troubleshoot/detect-enable-and-disable-smbv1-v2-v3) +- [File, Folder and Share Permission Utility Tool](https://web.archive.org/web/20200318052717/https://gallery.technet.microsoft.com/scriptcenter/File-Folder-and-Share-f788312b) +- [File Checksum Integrity Verifier](https://web.archive.org/web/20150302180951/https://support.microsoft.com/kb/841290) +- [CERTUTIL](https://ss64.com/nt/certutil.html) +- [Policy Analyzer](https://docs.microsoft.com/archive/blogs/secguide/new-tool-policy-analyzer) +- [Group Policy Management Console SP1](https://www.microsoft.com/download/details.aspx?id=21895) +- [Object Settings spreadsheet 2003/2008/2008R2/Win7](https://www.microsoft.com/download/details.aspx?id=25250) +- [Microsoft PowerToys (Github)](https://github.com/Microsoft/PowerToys) +- [Windows 11 ISO](https://www.microsoft.com/en-us/software-download/windows11) + +## Tools for Deployment + +- [Windows 11 Installation Assistant](https://www.microsoft.com/software-download/windows11) +- [Install Windows 11 Without a Microsoft Account](https://www.tomshardware.com/how-to/install-windows-11-without-microsoft-account) +- [Windows ADK 23H2](https://www.microsoft.com/en-us/download/details.aspx?id=105667) +- [Windows ADK 24H2](https://www.microsoft.com/en-us/download/details.aspx?id=106254) +- [Windows Server 25](https://www.microsoft.com/en-us/download/details.aspx?id=106295) +- [Microsoft Deployment Toolkit](https://docs.microsoft.com/mem/configmgr/mdt/) +- [Windows Assessment and Deployment Kit](https://docs.microsoft.com/windows-hardware/get-started/adk-install) +- [Rufus USB formatting tool](https://rufus.ie/en/) +- [Windows 10 Update Assistant 22H2](https://www.microsoft.com/software-download/windows10) +- [Windows 10 ISO](https://www.microsoft.com/software-download/windows10ISO) +- [Windows 10 Pro for Workstations](https://www.microsoft.com/p/windows-10-pro-for-workstations/dg7gmgf0dw9s) +- [Locale Builder 2.0](https://www.microsoft.com/download/details.aspx?id=41158) + +## Package Management + +- [Ansible](https://www.ansible.com/how-ansible-works/) +- [Chocolatey](https://chocolatey.org/) +- [Ninite](https://ninite.com/) +- [Scoop](https://scoop.sh/) +- [Windows Package Manager (WinGet)](https://devblogs.microsoft.com/commandline/windows-package-manager-1-1/) +- [AppGet](https://devblogs.microsoft.com/commandline/winget-install-learning/) + +## Command-line Utilities + +- [SysInternals](https://docs.microsoft.com/sysinternals/) +- [bottom](https://github.com/ClementTsang/bottom) — cross-platform graphical process/system monitor +- [Caffeine.exe](https://www.zhornsoftware.co.uk/caffeine/index.html) — prevent sleep/lock +- [CMDebug](https://jpsoft.com/products/cmdebug.html) — batch file debugger +- [Console 2](https://github.com/cbucher/console) | [review](https://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt) +- [ConEmu-Maximus5](https://conemu.github.io/) | [review](https://www.hanselman.com/blog/ConEmuTheWindowsTerminalConsolePromptWeveBeenWaitingFor) +- [CopyTrans Manager](https://www.copytrans.net/copytransmanager/) | [CopyTrans Filey](https://www.copytrans.net/copytransfiley/) +- [CryptoPrevent](https://www.bleepingcomputer.com/virus-removal/cryptolocker-ransomware-information) +- [Cygwin](https://cygwin.com/) — [Part 1](https://lifehacker.com/179514/geek-to-live--introduction-to-cygwin-part-i) | [Part 2](https://lifehacker.com/180690/geek-to-live--introduction-to-cygwin-part-ii---more-useful-commands) | [Part 3](https://lifehacker.com/181282/geek-to-live--introduction-to-cygwin-part-iii---scripts-packages-and-more) +- [DOFF](https://ss64.com/links/doff10.zip) | [source](https://ss64.com/links/doff10_source.zip) +- [FastCopy](https://fastcopy.jp/) +- [FindRepl.bat](https://www.dostips.com/forum/viewtopic.php?f=3&t=4697) — find and replace in text files +- [Gow](https://github.com/bmatzelle/gow) — GNU on Windows (lightweight Cygwin alternative) +- [ImageMagick](https://www.imagemagick.org/) | [scripts](https://web.archive.org/web/20240416181228/http://www.fmwconcepts.com/imagemagick/index.php) +- [Jdupes](https://codeberg.org/jbruchon/jdupes) — duplicate file finder +- [Joeware.net](https://www.joeware.net/freetools/) — AD and Windows tools +- [Karen's directory printer](https://www.karenware.com/powertools/karens-directory-printer) +- [Microsoft Mouse without Borders](https://www.microsoft.com/en-ca/download/details.aspx?id=35460) +- [MParallel](https://github.com/lordmulder/MParallel) — parallel command execution +- [Nirsoft Utilities](https://www.nirsoft.net/) +- [NirCMD](https://www.nirsoft.net/utils/nircmd.html) — command-line automation utility +- [NSIS](https://nsis.sourceforge.io/Main_Page) — installer creation +- [Npocmaka batch scripts](https://github.com/npocmaka/batch.scripts) +- [zipjs.bat](https://stackoverflow.com/questions/28043589/how-can-i-compress-zip-and-uncompress-unzip-files-and-folders-with-bat) +- [PDFtk](https://www.pdflabs.com/tools/pdftk-server/) — PDF manipulation +- [Petter Nordahl-Hagen](https://pogostick.net/~pnh/ntpasswd/main.html) — NT password recovery +- [pretentiousname utilities](https://www.pretentiousname.com/miscsoft/index.html) +- [Repl.bat](https://www.dostips.com/forum/viewtopic.php?f=3&t=3855) — regex replace in text files +- [Ritchie Lawrence tools](https://github.com/ritchielawrence/) | [cmdow](https://github.com/ritchielawrence/cmdow) +- [SetACL](https://helgeklein.com/setacl/) — permission management +- [SetRes](https://atrandom.iansharpe.com/setres.php) — screen resolution changer +- [SoX](https://sourceforge.net/projects/sox/files/sox//) — audio processing +- [Bill Stewart utilities](https://westmesatech.com/?page_id=23) +- [System Tools (Somarsoft)](https://www.systemtools.com/somarsoft/) +- [WebP utilities](https://developers.google.com/speed/webp/download) + +### Wake-on-LAN + +- [Depicus](https://www.depicus.com/wake-on-lan/wake-on-lan-cmd) +- [Gammadyne](https://www.gammadyne.com/cmdline.htm#wol) +- [Nirsoft WOL](https://www.nirsoft.net/utils/wake_on_lan.html) +- [PowerShell Wake On LAN script](https://powershell.one/code/11.html) + +## Alternative Terminals + +- [Windows Terminal](https://apps.microsoft.com/detail/9N0DX20HK701) | [GitHub](https://github.com/microsoft/terminal) +- [ConEmu](https://conemu.github.io/) +- [ConsoleZ](https://github.com/cbucher/console) +- [Fluent Terminal](https://github.com/felixse/FluentTerminal) +- [Hyper](https://hyper.is/) +- [MinTTY](https://mintty.github.io/) +- [MobaXterm](https://mobaxterm.mobatek.net/) +- [Tabby](https://tabby.sh/) +- [ZOC](https://www.emtec.com/zoc/) diff --git a/skills/batch-files/references/windows-commands.md b/skills/batch-files/references/windows-commands.md new file mode 100644 index 000000000..fb64c3d2b --- /dev/null +++ b/skills/batch-files/references/windows-commands.md @@ -0,0 +1,832 @@ +# Windows Commands Reference (A-Z) + +Comprehensive command reference from [learn.microsoft.com](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands). + +## A + +- [active](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/active) +- [add](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/add) + - [add alias](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/add-alias) + - [add volume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/add-volume) +- [adprep](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/adprep) +- [append](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/append) +- [arp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/arp) +- [assign](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/assign) +- [assoc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/assoc) +- [at](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/at) +- [atmadm](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/atmadm) +- [attach-vdisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attach-vdisk) +- [attrib](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib) +- [attributes](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attributes) + - [attributes disk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attributes-disk) + - [attributes volume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attributes-volume) +- [auditpol](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol) + - [auditpol backup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol-backup) + - [auditpol clear](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol-clear) + - [auditpol get](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol-get) + - [auditpol list](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol-list) + - [auditpol remove](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol-remove) + - [auditpol resourcesacl](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol-resourcesacl) + - [auditpol restore](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol-restore) + - [auditpol set](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/auditpol-set) +- [autochk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/autochk) +- [autoconv](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/autoconv) +- [autofmt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/autofmt) +- [automount](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/automount) + +## B + +- [bcdboot](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bcdboot) +- [bcdedit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bcdedit) +- [bdehdcfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bdehdcfg) + - [bdehdcfg driveinfo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bdehdcfg-driveinfo) + - [bdehdcfg newdriveletter](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bdehdcfg-newdriveletter) + - [bdehdcfg quiet](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bdehdcfg-quiet) + - [bdehdcfg restart](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bdehdcfg-restart) + - [bdehdcfg size](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bdehdcfg-size) + - [bdehdcfg target](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bdehdcfg-target) +- [begin backup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/begin-backup) +- [begin restore](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/begin-restore) +- [bitsadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin) + - [bitsadmin addfile](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-addfile) + - [bitsadmin addfileset](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-addfileset) + - [bitsadmin addfilewithranges](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-addfilewithranges) + - [bitsadmin cache](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache) + - [bitsadmin cancel](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cancel) + - [bitsadmin complete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-complete) + - [bitsadmin create](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-create) + - [bitsadmin examples](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-examples) + - [bitsadmin getaclflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getaclflags) + - [bitsadmin getbytestotal](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getbytestotal) + - [bitsadmin getbytestransferred](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getbytestransferred) + - [bitsadmin getclientcertificate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getclientcertificate) + - [bitsadmin getcompletiontime](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getcompletiontime) + - [bitsadmin getcreationtime](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getcreationtime) + - [bitsadmin getcustomheaders](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getcustomheaders) + - [bitsadmin getdescription](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getdescription) + - [bitsadmin getdisplayname](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getdisplayname) + - [bitsadmin geterror](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-geterror) + - [bitsadmin geterrorcount](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-geterrorcount) + - [bitsadmin getfilestotal](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getfilestotal) + - [bitsadmin getfilestransferred](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getfilestransferred) + - [bitsadmin gethelpertokenflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-gethelpertokenflags) + - [bitsadmin gethelpertokensid](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-gethelpertokensid) + - [bitsadmin gethttpmethod](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-gethttpmethod) + - [bitsadmin getmaxdownloadtime](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getmaxdownloadtime) + - [bitsadmin getminretrydelay](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getminretrydelay) + - [bitsadmin getmodificationtime](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getmodificationtime) + - [bitsadmin getnoprogresstimeout](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getnoprogresstimeout) + - [bitsadmin getnotifycmdline](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getnotifycmdline) + - [bitsadmin getnotifyflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getnotifyflags) + - [bitsadmin getnotifyinterface](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getnotifyinterface) + - [bitsadmin getowner](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getowner) + - [bitsadmin getpeercachingflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getpeercachingflags) + - [bitsadmin getpriority](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getpriority) + - [bitsadmin getproxybypasslist](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getproxybypasslist) + - [bitsadmin getproxylist](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getproxylist) + - [bitsadmin getproxyusage](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getproxyusage) + - [bitsadmin getreplydata](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getreplydata) + - [bitsadmin getreplyfilename](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getreplyfilename) + - [bitsadmin getreplyprogress](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getreplyprogress) + - [bitsadmin getsecurityflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getsecurityflags) + - [bitsadmin getstate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getstate) + - [bitsadmin gettemporaryname](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-gettemporaryname) + - [bitsadmin gettype](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-gettype) + - [bitsadmin getvalidationstate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-getvalidationstate) + - [bitsadmin help](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-help) + - [bitsadmin info](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-info) + - [bitsadmin list](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-list) + - [bitsadmin listfiles](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-listfiles) + - [bitsadmin makecustomheaderswriteonly](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-makecustomheaderswriteonly) + - [bitsadmin monitor](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-monitor) + - [bitsadmin nowrap](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-nowrap) + - [bitsadmin peercaching](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peercaching) + - [bitsadmin peers](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peers) + - [bitsadmin rawreturn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-rawreturn) + - [bitsadmin removeclientcertificate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-removeclientcertificate) + - [bitsadmin removecredentials](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-removecredentials) + - [bitsadmin replaceremoteprefix](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-replaceremoteprefix) + - [bitsadmin reset](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-reset) + - [bitsadmin resume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-resume) + - [bitsadmin setaclflag](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setaclflag) + - [bitsadmin setclientcertificatebyid](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setclientcertificatebyid) + - [bitsadmin setclientcertificatebyname](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setclientcertificatebyname) + - [bitsadmin setcredentials](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setcredentials) + - [bitsadmin setcustomheaders](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setcustomheaders) + - [bitsadmin setdescription](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setdescription) + - [bitsadmin setdisplayname](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setdisplayname) + - [bitsadmin sethelpertoken](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-sethelpertoken) + - [bitsadmin sethelpertokenflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-sethelpertokenflags) + - [bitsadmin sethttpmethod](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-sethttpmethod) + - [bitsadmin setmaxdownloadtime](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setmaxdownloadtime) + - [bitsadmin setminretrydelay](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setminretrydelay) + - [bitsadmin setnoprogresstimeout](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setnoprogresstimeout) + - [bitsadmin setnotifycmdline](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setnotifycmdline) + - [bitsadmin setnotifyflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setnotifyflags) + - [bitsadmin setpeercachingflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setpeercachingflags) + - [bitsadmin setpriority](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setpriority) + - [bitsadmin setproxysettings](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setproxysettings) + - [bitsadmin setreplyfilename](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setreplyfilename) + - [bitsadmin setsecurityflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setsecurityflags) + - [bitsadmin setvalidationstate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-setvalidationstate) + - [bitsadmin suspend](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-suspend) + - [bitsadmin takeownership](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-takeownership) + - [bitsadmin transfer](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-transfer) + - [bitsadmin util](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-util) + - [bitsadmin wrap](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-wrap) + - [bitsadmin cache and delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-delete) + - [bitsadmin cache and deleteurl](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-deleteurl) + - [bitsadmin cache and getexpirationtime](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-getexpirationtime) + - [bitsadmin cache and getlimit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-getlimit) + - [bitsadmin cache and help](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-help) + - [bitsadmin cache and info](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-info) + - [bitsadmin cache and list](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-list) + - [bitsadmin cache and setexpirationtime](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-setexpirationtime) + - [bitsadmin cache and setlimit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-and-setlimit) + - [bitsadmin cache and clear](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-cache-clear) + - [bitsadmin peercaching and getconfigurationflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peercaching-and-getconfigurationflags) + - [bitsadmin peercaching and help](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peercaching-and-help) + - [bitsadmin peercaching and setconfigurationflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peercaching-and-setconfigurationflags) + - [bitsadmin peers and clear](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peers-and-clear) + - [bitsadmin peers and discover](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peers-and-discover) + - [bitsadmin peers and help](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peers-and-help) + - [bitsadmin peers and list](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-peers-and-list) + - [bitsadmin util and enableanalyticchannel](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-util-and-enableanalyticchannel) + - [bitsadmin util and getieproxy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-util-and-getieproxy) + - [bitsadmin util and help](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-util-and-help) + - [bitsadmin util and repairservice](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-util-and-repairservice) + - [bitsadmin util and setieproxy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-util-and-setieproxy) + - [bitsadmin util and version](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin-util-and-version) +- [bootcfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg) + - [bootcfg addsw](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-addsw) + - [bootcfg copy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-copy) + - [bootcfg dbg1394](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-dbg1394) + - [bootcfg debug](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-debug) + - [bootcfg default](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-default) + - [bootcfg delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-delete) + - [bootcfg ems](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-ems) + - [bootcfg query](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-query) + - [bootcfg raw](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-raw) + - [bootcfg rmsw](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-rmsw) + - [bootcfg timeout](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bootcfg-timeout) +- [break](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/break) + +## C + +- [cacls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cacls) +- [call](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/call) +- [cd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cd) +- [certreq](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/certreq_1) +- [certutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/certutil) +- [change](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/change) + - [change logon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/change-logon) + - [change port](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/change-port) + - [change user](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/change-user) +- [chcp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp) +- [chdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chdir) +- [chglogon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chglogon) +- [chgport](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chgport) +- [chgusr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chgusr) +- [chkdsk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chkdsk) +- [chkntfs](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chkntfs) +- [choice](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/choice) +- [cipher](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cipher) +- [clean](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/clean) +- [cleanmgr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cleanmgr) +- [clip](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/clip) +- [cls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cls) +- [cmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd) +- [cmdkey](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmdkey) +- [cmstp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmstp) +- [color](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/color) +- [comp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/comp) +- [compact](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/compact) + - [compact vdisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/compact-vdisk) +- [convert](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/convert) + - [convert basic](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/convert-basic) + - [convert dynamic](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/convert-dynamic) + - [convert gpt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/convert-gpt) + - [convert mbr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/convert-mbr) +- [copy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/copy) +- [create](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create) + - [create partition efi](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-partition-efi) + - [create partition extended](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-partition-extended) + - [create partition logical](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-partition-logical) + - [create partition msr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-partition-msr) + - [create partition primary](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-partition-primary) + - [create volume mirror](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-volume-mirror) + - [create volume raid](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-volume-raid) + - [create volume simple](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-volume-simple) + - [create volume stripe](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/create-volume-stripe) +- [cscript](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cscript) + +## D + +- [date](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/date) +- [dcdiag](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dcdiag) +- [dcgpofix](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dcgpofix) +- [dcpromo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dcpromo) +- [defrag](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/defrag) +- [del](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/del) +- [delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/delete) + - [delete disk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/delete-disk) + - [delete partition](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/delete-partition) + - [delete shadows](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/delete-shadows) + - [delete volume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/delete-volume) +- [detach vdisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/detach-vdisk) +- [detail](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/detail) + - [detail disk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/detail-disk) + - [detail partition](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/detail-partition) + - [detail vdisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/detail-vdisk) + - [detail volume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/detail-volume) +- [dfsdiag](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsdiag) + - [dfsdiag testdcs](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsdiag-testdcs) + - [dfsdiag testdfsconfig](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsdiag-testdfsconfig) + - [dfsdiag testdfsintegrity](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsdiag-testdfsintegrity) + - [dfsdiag testreferral](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsdiag-testreferral) + - [dfsdiag testsites](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsdiag-testsites) +- [dfsrmig](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsrmig) +- [diantz](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diantz) +- [dir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dir) +- [diskcomp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskcomp) +- [diskcopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskcopy) +- [diskpart](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskpart) +- [diskperf](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskperf) +- [diskraid](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskraid) +- [diskshadow](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskshadow) +- [dispdiag](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dispdiag) +- [dnscmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dnscmd) +- [doskey](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/doskey) +- [driverquery](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/driverquery) +- [dtrace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dtrace) + +## E + +- [echo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/echo) +- [edit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/edit) +- [endlocal](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/endlocal) +- [end restore](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/end-restore) +- [erase](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/erase) +- [eventcreate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/eventcreate) +- [Evntcmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/evntcmd) +- [exec](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/exec) +- [exit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/exit) +- [expand](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/expand) + - [expand vdisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/expand-vdisk) +- [expose](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/expose) +- [extend](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/extend) +- [extract](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/extract) + +## F + +- [fc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fc) +- [filesystems](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/filesystems) +- [find](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/find) +- [findstr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/findstr) +- [finger](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/finger) +- [flattemp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/flattemp) +- [fondue](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fondue) +- [for](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/for) +- [forfiles](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/forfiles) +- [format](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/format) +- [freedisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/freedisk) +- [fsutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil) + - [fsutil 8dot3name](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-8dot3name) + - [fsutil behavior](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-behavior) + - [fsutil devdrv](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-devdrv) + - [fsutil dirty](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-dirty) + - [fsutil file](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-file) + - [fsutil fsinfo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-fsinfo) + - [fsutil hardlink](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-hardlink) + - [fsutil objectid](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-objectid) + - [fsutil quota](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-quota) + - [fsutil repair](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-repair) + - [fsutil reparsepoint](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-reparsepoint) + - [fsutil resource](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-resource) + - [fsutil sparse](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-sparse) + - [fsutil tiering](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-tiering) + - [fsutil transaction](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-transaction) + - [fsutil usn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-usn) + - [fsutil volume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-volume) + - [fsutil wim](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-wim) +- [ftp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp) + - [ftp append](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-append) + - [ftp ascii](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-ascii) + - [ftp bell](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-bell_1) + - [ftp binary](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-binary) + - [ftp bye](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-bye) + - [ftp cd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-cd) + - [ftp close](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-close_1) + - [ftp debug](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-debug) + - [ftp delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-delete) + - [ftp dir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-dir) + - [ftp disconnect](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-disconnect_1) + - [ftp get](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-get) + - [ftp glob](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-glob_1) + - [ftp hash](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-hash_1) + - [ftp lcd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-lcd) + - [ftp literal](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-literal_1) + - [ftp ls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-ls_1) + - [ftp mdelete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp.mdelete_1) + - [ftp mdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp.mdir) + - [ftp mget](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-mget) + - [ftp mkdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-mkdir) + - [ftp mls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-mls_1) + - [ftp mput](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-mput_1) + - [ftp open](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-open_1) + - [ftp prompt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-prompt_1) + - [ftp put](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-put) + - [ftp pwd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-pwd_1) + - [ftp quit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-quit) + - [ftp quote](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-quote) + - [ftp recv](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-recv) + - [ftp remotehelp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-remotehelp_1) + - [ftp rename](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-rename) + - [ftp rmdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-rmdir) + - [ftp send](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-send_1) + - [ftp status](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-status) + - [ftp trace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-trace_1) + - [ftp type](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-type) + - [ftp user](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-user) + - [ftp verbose](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftp-verbose_1) +- [ftype](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftype) +- [fveupdate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fveupdate) + +## G + +- [getmac](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/getmac) +- [gettype](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gettype) +- [goto](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/goto) +- [gpfixup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gpfixup) +- [gpresult](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gpresult) +- [gpt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gpt) +- [gpupdate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gpupdate) +- [graftabl](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/graftabl) + +## H + +- [help](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/help) +- [helpctr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/helpctr) +- [hostname](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/hostname) + +## I + +- [icacls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/icacls) +- [if](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if) +- [import (shadowdisk)](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/import) +- [import (diskpart)](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/import_1) +- [inactive](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/inactive) +- [ipconfig](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ipconfig) +- [ipxroute](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ipxroute) +- [irftp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/irftp) + +## J-K + +- [jetpack](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/jetpack) +- [klist](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/klist) +- [ksetup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup) + - [ksetup addenctypeattr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-addenctypeattr) + - [ksetup addhosttorealmmap](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-addhosttorealmmap) + - [ksetup addkdc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-addkdc) + - [ksetup addkpasswd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-addkpasswd) + - [ksetup addrealmflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-addrealmflags) + - [ksetup changepassword](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-changepassword) + - [ksetup delenctypeattr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-delenctypeattr) + - [ksetup delhosttorealmmap](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-delhosttorealmmap) + - [ksetup delkdc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-delkdc) + - [ksetup delkpasswd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-delkpasswd) + - [ksetup delrealmflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-delrealmflags) + - [ksetup domain](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-domain) + - [ksetup dumpstate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-dumpstate) + - [ksetup getenctypeattr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-getenctypeattr) + - [ksetup listrealmflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-listrealmflags) + - [ksetup mapuser](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-mapuser) + - [ksetup removerealm](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-removerealm) + - [ksetup server](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-server) + - [ksetup setcomputerpassword](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-setcomputerpassword) + - [ksetup setenctypeattr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-setenctypeattr) + - [ksetup setrealm](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-setrealm) + - [ksetup setrealmflags](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ksetup-setrealmflags) +- [ktmutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ktmutil) +- [ktpass](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ktpass) + +## L + +- [label](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/label) +- [list](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/list) + - [list providers](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/list-providers) + - [list shadows](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/list-shadows) + - [list writers](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/list-writers) +- [load metadata](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/load-metadata) +- [lodctr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/lodctr) +- [logman](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman) + - [logman create](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-create) + - [logman create alert](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-create-alert) + - [logman create api](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-create-api) + - [logman create cfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-create-cfg) + - [logman create counter](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-create-counter) + - [logman create trace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-create-trace) + - [logman delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-delete) + - [logman import and logman export](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-import-export) + - [logman query](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-query) + - [logman start and logman stop](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-start-stop) + - [logman update](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-update) + - [logman update alert](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-update-alert) + - [logman update api](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-update-api) + - [logman update cfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-update-cfg) + - [logman update counter](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-update-counter) + - [logman update trace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logman-update-trace) +- [logoff](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logoff) +- [lpq](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/lpq) +- [lpr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/lpr) + +## M + +- [macfile](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/macfile) +- [makecab](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/makecab) +- [manage bde](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde) + - [manage bde status](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-status) + - [manage bde on](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-on) + - [manage bde off](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-off) + - [manage bde pause](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-pause) + - [manage bde resume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-resume) + - [manage bde lock](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-lock) + - [manage bde unlock](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-unlock) + - [manage bde autounlock](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-autounlock) + - [manage bde protectors](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-protectors) + - [manage bde tpm](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-tpm) + - [manage bde setidentifier](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-setidentifier) + - [manage bde forcerecovery](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-forcerecovery) + - [manage bde changepassword](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-changepassword) + - [manage bde changepin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-changepin) + - [manage bde changekey](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-changekey) + - [manage bde keypackage](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-keypackage) + - [manage bde upgrade](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-upgrade) + - [manage bde wipefreespace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/manage-bde-wipefreespace) +- [mapadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mapadmin) +- [md](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/md) +- [merge vdisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/merge-vdisk) +- [mkdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mkdir) +- [mklink](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink) +- [mmc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mmc) +- [mode](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mode) +- [more](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/more) +- [mount](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mount) +- [mountvol](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mountvol) +- [move](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/move) +- [mqbkup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mqbkup) +- [mqsvc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mqsvc) +- [mqtgsvc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mqtgsvc) +- [msdt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msdt) +- [msg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msg) +- [msiexec](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec) +- [msinfo32](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msinfo32) +- [mstsc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mstsc) + +## N + +- [nbtstat](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nbtstat) +- [netcfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netcfg) +- [netdom](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom) + - [netdom add](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-add) + - [netdom computername](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-computername) + - [netdom join](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-join) + - [netdom move](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-move) + - [netdom movent4bdc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-movent4bdc) + - [netdom query](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-query) + - [netdom remove](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-remove) + - [netdom renamecomputer](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-renamecomputer) + - [netdom reset](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-reset) + - [netdom resetpwd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-resetpwd) + - [netdom trust](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-trust) + - [netdom verify](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netdom-verify) +- [net print](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/net-print) +- [net user](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/net-user) +- [netsh](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh) + - [netsh add](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-add) + - [netsh advfirewall](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-advfirewall) + - [netsh branchcache](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-branchcache) + - [netsh bridge](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-bridge) + - [netsh delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-delete) + - [netsh dhcpclient](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-dhcpclient) + - [netsh dnsclient](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-dnsclient) + - [netsh dump](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-dump) + - [netsh exec](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-exec) + - [netsh http](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-http) + - [netsh interface](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-interface) + - [netsh ipsec](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-ipsec) + - [netsh lan](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-lan) + - [netsh mbn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-mbn) + - [netsh namespace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-namespace) + - [netsh netio](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-netio) + - [netsh nlm](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-nlm) + - [netsh ras](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-ras) + - [netsh rpc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-rpc) + - [netsh set](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-set) + - [netsh show](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-show) + - [netsh trace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-trace) + - [netsh wcn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-wcn) + - [netsh wfp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-wfp) + - [netsh winhttp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-winhttp) + - [netsh winsock](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-winsock) + - [netsh wlan](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-wlan) +- [netstat](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netstat) +- [nfsadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nfsadmin) +- [nfsshare](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nfsshare) +- [nfsstat](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nfsstat) +- [nlbmgr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nlbmgr) +- [nltest](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc731935(v=ws.11)) +- [nslookup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup) + - [nslookup exit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-exit-command) + - [nslookup finger](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-finger-command) + - [nslookup help](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-help) + - [nslookup ls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-ls) + - [nslookup lserver](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-lserver) + - [nslookup root](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-root) + - [nslookup server](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-server) + - [nslookup set](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set) + - [nslookup set all](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-all) + - [nslookup set class](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-class) + - [nslookup set d2](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-d2) + - [nslookup set debug](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-debug) + - [nslookup set domain](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-domain) + - [nslookup set port](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-port) + - [nslookup set querytype](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-querytype) + - [nslookup set recurse](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-recurse) + - [nslookup set retry](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-retry) + - [nslookup set root](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-root) + - [nslookup set search](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-search) + - [nslookup set srchlist](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-srchlist) + - [nslookup set timeout](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-timeout) + - [nslookup set type](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-type) + - [nslookup set vc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-set-vc) + - [nslookup view](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup-view) +- [ntbackup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ntbackup) +- [ntcmdprompt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ntcmdprompt) +- [ntfrsutl](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ntfrsutl) + +## O + +- [offline](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/offline) + - [offline disk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/offline-disk) + - [offline volume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/offline-volume) +- [online](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/online) + - [online disk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/online-disk) + - [online volume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/online-volume) +- [openfiles](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/openfiles) + +## P + +- [pagefileconfig](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pagefileconfig) +- [path](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/path) +- [pathping](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pathping) +- [pause](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pause) +- [pbadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pbadmin) +- [pentnt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pentnt) +- [perfmon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/perfmon) +- [ping](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ping) +- [pktmon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pktmon) +- [pnpunattend](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pnpunattend) +- [pnputil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pnputil) +- [popd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/popd) +- [powershell](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/powershell) +- [powershell ise](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/powershell_ise) +- [print](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/print) +- [prncnfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prncnfg) +- [prndrvr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prndrvr) +- [prnjobs](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prnjobs) +- [prnmngr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prnmngr) +- [prnport](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prnport) +- [prnqctl](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prnqctl) +- [prompt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prompt) +- [pubprn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pubprn) +- [pushd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pushd) +- [pushprinterconnections](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pushprinterconnections) +- [pwlauncher](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pwlauncher) +- [pwsh](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pwsh) + +## Q + +- [qappsrv](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/qappsrv) +- [qprocess](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/qprocess) +- [query](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/query) + - [query process](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/query-process) + - [query session](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/query-session) + - [query termserver](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/query-termserver) + - [query user](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/query-user) +- [quser](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/quser) +- [qwinsta](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/qwinsta) + +## R + +- [rd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rd) +- [rdpsign](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rdpsign) +- [recover](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/recover) +- [recover disk group](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/recover_1) +- [refsutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil) + - [refsutil compression](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil-compression) + - [refsutil dedup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil-dedup) + - [refsutil fixboot](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil-fixboot) + - [refsutil iometrics](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil-iometrics) + - [refsutil leak](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil-leak) + - [refsutil salvage](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil-salvage) + - [refsutil streamsnapshot](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil-streamsnapshot) + - [refsutil triage](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/refsutil-triage) +- [reg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg) + - [reg add](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-add) + - [reg compare](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-compare) + - [reg copy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-copy) + - [reg delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-delete) + - [reg export](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-export) + - [reg import](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-import) + - [reg load](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-load) + - [reg query](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-query) + - [reg restore](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-restore) + - [reg save](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-save) + - [reg unload](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-unload) +- [regini](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/regini) +- [regsvr32](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/regsvr32) +- [relog](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/relog) +- [rem](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rem) +- [remove](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/remove) +- [ren](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ren) +- [rename](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rename) +- [repair](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/repair) + - [repair bde](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/repair-bde) +- [repadmin](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc770963(v=ws.11)) +- [replace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/replace) +- [rescan](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rescan) +- [reset](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reset) + - [reset session](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reset-session) +- [retain](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/retain) +- [revert](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/revert) +- [rexec](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rexec) +- [risetup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/risetup) +- [rmdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rmdir) +- [robocopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy) +- [route](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/route_ws2008) +- [rpcinfo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rpcinfo) +- [rpcping](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rpcping) +- [rsh](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rsh) +- [rundll32](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32) + - [rundll32 printui](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32-printui) +- [rwinsta](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rwinsta) + +## S + +- [san](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/san) +- [sc config](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-config) +- [sc create](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-create) +- [sc delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-delete) +- [sc query](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-query) +- [schtasks](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks) +- [scwcmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/scwcmd) + - [scwcmd analyze](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/scwcmd-analyze) + - [scwcmd configure](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/scwcmd-configure) + - [scwcmd register](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/scwcmd-register) + - [scwcmd rollback](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/scwcmd-rollback) + - [scwcmd transform](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/scwcmd-transform) + - [scwcmd view](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/scwcmd-view) +- [secedit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/secedit) + - [secedit analyze](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/secedit-analyze) + - [secedit configure](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/secedit-configure) + - [secedit export](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/secedit-export) + - [secedit generaterollback](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/secedit-generaterollback) + - [secedit import](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/secedit-import) + - [secedit validate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/secedit-validate) +- [select](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/select) + - [select disk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/select-disk) + - [select partition](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/select-partition) + - [select vdisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/select-vdisk) + - [select volume](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/select-volume) +- [serverceipoptin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/serverceipoptin) +- [servermanagercmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/servermanagercmd) +- [serverweroptin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/serverweroptin) +- [set (environment variables)](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set_1) +- [set (shadow copy)](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set) + - [set context](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set-context) + - [set id](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set-id) + - [set metadata](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set-metadata) + - [set option](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set-option) + - [set verbose](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set-verbose) +- [setlocal](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setlocal) +- [setspn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setspn) +- [setx](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setx) +- [sfc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sfc) +- [shadow](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shadow) +- [shift](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shift) +- [showmount](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/showmount) +- [shrink](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shrink) +- [shutdown](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shutdown) +- [simulate restore](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/simulate-restore) +- [sort](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sort) +- [start](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start) +- [subst](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/subst) +- [sxstrace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sxstrace) +- [sysmon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sysmon) +- [sysocmgr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sysocmgr) +- [systeminfo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/systeminfo) + +### WDS Subcommands + +- [set device](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-set-device) +- [set drivergroup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-set-drivergroup) +- [set drivergroupfilter](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-set-drivergroupfilter) +- [set driverpackage](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-set-driverpackage) +- [set image](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-set-image) +- [set imagegroup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-set-imagegroup) +- [set server](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-set-server) +- [set transportserver](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-set-transportserver) +- [start multicasttransmission](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-start-multicasttransmission) +- [start namespace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-start-namespace) +- [start server](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-start-server) +- [start transportserver](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-start-transportserver) +- [stop server](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-stop-server) +- [stop transportserver](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil-stop-transportserver) + +## T + +- [takeown](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/takeown) +- [tapicfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tapicfg) +- [taskkill](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill) +- [tasklist](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tasklist) +- [tcmsetup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tcmsetup) +- [telnet](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet) + - [telnet close](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet-close) + - [telnet display](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet-display) + - [telnet open](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet-open) + - [telnet quit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet-quit) + - [telnet send](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet-send) + - [telnet set](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet-set) + - [telnet status](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet-status) + - [telnet unset](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/telnet-unset) +- [tftp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tftp) +- [time](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/time) +- [timeout](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/timeout) +- [title](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/title) +- [tlntadmn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tlntadmn) +- [tpmtool](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tpmtool) +- [tpmvscmgr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tpmvscmgr) +- [tracerpt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tracerpt) +- [tracert](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tracert) +- [tree](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tree) +- [tscon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tscon) +- [tsdiscon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tsdiscon) +- [tsecimp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tsecimp) +- [tskill](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tskill) +- [tsprof](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tsprof) +- [type](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/type) +- [typeperf](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/typeperf) +- [tzutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tzutil) + +## U-V + +- [unexpose](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/unexpose) +- [uniqueid](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/uniqueid) +- [unlodctr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/unlodctr) +- [ver](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ver) +- [verifier](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/verifier) +- [verify](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/verify) +- [vol](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/vol) +- [vssadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/vssadmin) + - [vssadmin delete shadows](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/vssadmin-delete-shadows) + - [vssadmin list shadows](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/vssadmin-list-shadows) + - [vssadmin list writers](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/vssadmin-list-writers) + - [vssadmin resize shadowstorage](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/vssadmin-resize-shadowstorage) + +## W + +- [waitfor](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/waitfor) +- [wbadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin) + - [wbadmin delete catalog](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-delete-catalog) + - [wbadmin delete systemstatebackup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-delete-systemstatebackup) + - [wbadmin disable backup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-disable-backup) + - [wbadmin enable backup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-enable-backup) + - [wbadmin get disks](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-get-disks) + - [wbadmin get items](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-get-items) + - [wbadmin get status](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-get-status) + - [wbadmin get versions](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-get-versions) + - [wbadmin restore catalog](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-restore-catalog) + - [wbadmin start backup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-start-backup) + - [wbadmin start recovery](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-start-recovery) + - [wbadmin start sysrecovery](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-start-sysrecovery) + - [wbadmin start systemstatebackup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-start-systemstatebackup) + - [wbadmin start systemstaterecovery](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-start-systemstaterecovery) + - [wbadmin stop job](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wbadmin-stop-job) +- [wdsutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wdsutil) +- [wecutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wecutil) +- [wevtutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wevtutil) +- [where](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/where) +- [whoami](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/whoami) +- [winnt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winnt) +- [winnt32](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winnt32) +- [winrs](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winrs) +- [winsat mem](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winsat-mem) +- [winsat mfmedia](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winsat-mfmedia) +- [wmic](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wmic) +- [writer](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/writer) +- [wscript](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wscript) + +## X + +- [xcopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy) diff --git a/skills/batch-files/references/windows-subsystem-on-linux.md b/skills/batch-files/references/windows-subsystem-on-linux.md new file mode 100644 index 000000000..e33d72373 --- /dev/null +++ b/skills/batch-files/references/windows-subsystem-on-linux.md @@ -0,0 +1,62 @@ +# Windows Subsystem for Linux (WSL) Reference + +## Documentation + +- [WSL Home](https://learn.microsoft.com/en-us/windows/wsl/) +- [What is the Windows Subsystem for Linux (WSL)?](https://learn.microsoft.com/en-us/windows/wsl/about) +- [Install WSL](https://learn.microsoft.com/en-us/windows/wsl/install) +- [Install Linux on Windows Server](https://learn.microsoft.com/en-us/windows/wsl/install-on-server) +- [Manual install steps](https://learn.microsoft.com/en-us/windows/wsl/install-manual) +- [Best practices for setting up a WSL development environment](https://learn.microsoft.com/en-us/windows/wsl/setup/environment) +- [Comparing WSL 1 and WSL 2](https://learn.microsoft.com/en-us/windows/wsl/compare-versions) +- [What's new with WSL 2?](https://learn.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2) +- [Frequently Asked Questions](https://learn.microsoft.com/en-us/windows/wsl/faq) +- [Windows Subsystem for Linux is now open source](https://blogs.windows.com/windowsdeveloper/2025/05/19/the-windows-subsystem-for-linux-is-now-open-source/) + +## Related Tools + +- [Microsoft PowerToys](https://learn.microsoft.com/en-us/windows/powertoys/) +- [Windows Package Manager](https://learn.microsoft.com/en-us/windows/package-manager/) +- [Windows Insiders Program](https://insider.windows.com/getting-started) + +## Blogs and Community + +- [Overview post with a collection of videos and blogs](https://blogs.msdn.microsoft.com/commandline/learn-about-windows-console-and-windows-subsystem-for-linux-wsl/) +- [Command-Line blog](https://blogs.msdn.microsoft.com/commandline/) +- [Windows Subsystem for Linux Blog](https://learn.microsoft.com/en-us/archive/blogs/wsl/) +- [GitHub issue tracker: WSL](https://github.com/microsoft/WSL/issues) +- [GitHub issue tracker: WSL documentation](https://github.com/MicrosoftDocs/WSL/issues) + +## Technical Documentation (wsl.dev) + +### Development + +- [Building and testing WSL](https://wsl.dev/dev-loop/) +- [Debugging WSL](https://wsl.dev/debugging/) + +### Components + +- [Overview](https://wsl.dev/technical-documentation/) +- [wsl.exe](https://wsl.dev/technical-documentation/wsl.exe/) +- [wslg.exe](https://wsl.dev/technical-documentation/wslg.exe/) +- [wslconfig.exe](https://wsl.dev/technical-documentation/wslconfig.exe/) +- [wslhost.exe](https://wsl.dev/technical-documentation/wslhost.exe/) +- [wslrelay.exe](https://wsl.dev/technical-documentation/wslrelay.exe/) +- [wslservice.exe](https://wsl.dev/technical-documentation/wslservice.exe/) + +### Internals + +- [mini_init](https://wsl.dev/technical-documentation/mini_init/) +- [init](https://wsl.dev/technical-documentation/init/) +- [session leader](https://wsl.dev/technical-documentation/session-leader/) +- [relay](https://wsl.dev/technical-documentation/relay/) +- [gns](https://wsl.dev/technical-documentation/gns/) +- [localhost](https://wsl.dev/technical-documentation/localhost/) +- [plan9](https://wsl.dev/technical-documentation/plan9/) + +### Architecture + +- [Boot process](https://wsl.dev/technical-documentation/boot-process/) +- [Interop](https://wsl.dev/technical-documentation/interop/) +- [Drvfs & Plan9](https://wsl.dev/technical-documentation/drvfs/) +- [Systemd](https://wsl.dev/technical-documentation/systemd/)