Command-line reference
Every headless command goes through the same entry point:
JunctionManager.bat <flags>
You can also call pwsh -NoProfile -File .\JunctionManager.ps1 <flags>.
Read-only commands
| Command | Description |
|---|---|
--list | List all modules and action IDs |
--search <query> | Search actions by ID, label, module name or module ID |
--scan [root] | Scan standard roots, or a custom directory at depth 2 |
--inspect <path> | Inspect one junction and print its status |
--export <file> [--csv] | Export the current inventory as JSON (default) or CSV |
--backup | Write a timestamped JSON snapshot under backups\ |
--help | Show help |
Mutating commands
| Command | Description |
|---|---|
--create <path> --target <dir> | Create a junction at <path> pointing to <dir> |
--retarget <path> --target <dir> | Point an existing junction at a new target |
--repair <path> [--target <dir>] | Recreate a missing junction or repair a stale one |
--remove <path> | Detach a junction; the target is kept |
--clean-stale | Remove every Stale-* junction |
--clean-orphaned | Remove junctions whose target is missing |
--clean-empty | Remove junctions whose target is empty |
--clean-stale-empty | Remove stale junctions and delete reclaimed empty targets |
--restore <file> | Recreate missing junctions from an inventory file |
Destructive commands require --yes or --dry-run. Without either, they refuse with exit code 2 and leave the filesystem untouched.
Options
| Option | Effect |
|---|---|
--dry-run, --what-if | Preview changes without writing |
--yes, -y | Confirm destructive headless actions |
--log [path] | Enable diagnostic logging; optional custom path |
--csv | Export CSV instead of JSON |
--no-pause | Skip trailing pauses (batch files) |
--path <value> | Supply a path when a positional path is inconvenient |
Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Operation failed, inspection found a missing path, or an exception occurred |
2 | Usage error: missing argument, unknown flag, or refused destructive action |
Examples
Inspect and scan
JunctionManager.bat --list
JunctionManager.bat --search clean
JunctionManager.bat --scan
JunctionManager.bat --scan "C:\Users\me\AppData\Local\Programs"
JunctionManager.bat --inspect "C:\Users\me\AppData\Local\Programs\App"
Create and manage
JunctionManager.bat --create "C:\Users\me\AppData\Local\Programs\App" --target "D:\Apps\App"
JunctionManager.bat --retarget "C:\Users\me\AppData\Local\Programs\App" --target "D:\Apps\App-2" --yes
JunctionManager.bat --repair "C:\Users\me\AppData\Local\Programs\App" --target "D:\Apps\App"
JunctionManager.bat --remove "C:\Users\me\AppData\Local\Programs\App" --yes
Clean safely
JunctionManager.bat --clean-stale --dry-run
JunctionManager.bat --clean-orphaned --dry-run
JunctionManager.bat --clean-empty --dry-run
JunctionManager.bat --clean-stale-empty --dry-run
JunctionManager.bat --clean-stale-empty --yes --log
Inventory and restore
JunctionManager.bat --export logs\inventory.json
JunctionManager.bat --export logs\inventory.csv --csv
JunctionManager.bat --backup
JunctionManager.bat --restore logs\inventory.json --dry-run
JunctionManager.bat --restore logs\inventory.json --yes
Scripting pattern
# Preview, then apply only if a preview shows work to do.
pwsh -NoProfile -File .\JunctionManager.ps1 --clean-stale --dry-run
if ($LASTEXITCODE -eq 0) {
pwsh -NoProfile -File .\JunctionManager.ps1 --clean-stale --yes
}
Output and logs
Human-readable output goes to standard output. Fatal usage errors go to standard error. When --log is enabled, the same session writes timestamped INFO, WARN, ERROR and DEBUG lines to logs\windows-junction-manager-YYYY-MM-DD.log.
See Safety and protected paths for the rules every command enforces.