Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

CommandDescription
--listList 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
--backupWrite a timestamped JSON snapshot under backups\
--helpShow help

Mutating commands

CommandDescription
--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-staleRemove every Stale-* junction
--clean-orphanedRemove junctions whose target is missing
--clean-emptyRemove junctions whose target is empty
--clean-stale-emptyRemove 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

OptionEffect
--dry-run, --what-ifPreview changes without writing
--yes, -yConfirm destructive headless actions
--log [path]Enable diagnostic logging; optional custom path
--csvExport CSV instead of JSON
--no-pauseSkip trailing pauses (batch files)
--path <value>Supply a path when a positional path is inconvenient

Exit codes

CodeMeaning
0Success
1Operation failed, inspection found a missing path, or an exception occurred
2Usage 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.