4 releases
Uses new Rust 2024
| 0.1.5 | Dec 13, 2025 |
|---|---|
| 0.1.4 | Dec 12, 2025 |
| 0.1.3 | Dec 11, 2025 |
| 0.1.2 |
|
| 0.1.1 | Dec 11, 2025 |
#244 in Command line utilities
41KB
960 lines
desktop-ini
A small CLI tool for working with directory desktop.ini files on Windows.
It helps you inspect and edit desktop.ini fields, manage tags, configure custom execution commands, and sync folder attributes.
Features
- Inspect a directory's
desktop.iniand show a concise, human-friendly summary. - Set common fields such as title, icon, InfoTip, tags (Prop5) and custom execution commands.
- Run the custom command defined in
desktop.ini, with optional second confirmation.- If elevation is required, it will automatically prompt for administrator permission (UAC) and retry.
- Sync all subdirectories that contain
desktop.ini, making the folders read-only. - Registry integration: register a custom directory class so Explorer can delegate opening to this program.
There is also a Chinese README: README_zh.md.
Install
# From the project root
cargo install --path .
After installation, the compiled binary (usually named desktop-ini, depending on your environment) will be placed in Cargo's bin directory.
Global options
All subcommands share these global options:
--path <DIR>: Target directory. Defaults to the current working directory.--error-action <MODE>: Error handling strategy, one of:continue: Print error and continue (default).inquire: Pause on error and wait for Enter.silently: Ignore errors without printing messages.stop: Abort immediately on error.
--dry-run: Simulation mode. Print what would be written, but do not actually modify files or attributes.
Subcommands
View directory info
desktop-ini show --path <DIR>
Prints a compact summary of the desktop.ini contents, including:
- Title (
LocalizedResourceName) - InfoTip
- Icon (
IconResource) - Tags (Prop5 parsed into a tag list)
- Custom execution command and its confirmation status
Edit desktop.ini
desktop-ini set \
--path <DIR> \
--name "Example folder" \
--icon "shell32.dll,4" \
--info-tip "This is an example" \
--add-tag work --add-tag rust \
--command "code" \
--args "%1" \
--confirm
Common options:
--name: Set directory display name (LocalizedResourceName).--icon: Set icon (IconResource), for example"shell32.dll,4".--info-tip: Set hover text (InfoTip).--add-tag/--remove-tag/--clear-tag: Manage tags stored in Prop5.- You can pass multiple
--add-tag/--remove-tag. --add-tagand--remove-tagalso accept comma-separated values.
- You can pass multiple
--command: Set the executable (Target) for custom execution.--args: Set arguments (Args) for custom execution.- You can pass multiple
--args. %1will be replaced with the directory path that containsdesktop.ini.- Use
%%for a literal%. - Quotes group arguments with whitespace; inside quotes,
\"and\\are supported.
- You can pass multiple
--confirm: Enable second confirmation before running the command.- If not provided and confirmation was previously enabled, the flag will be turned off.
Use --dry-run to preview changes and the final desktop.ini content without actually writing.
Execute the configured command
desktop-ini run --path <DIR>
- If confirmation is enabled, you will be prompted:
y/yes: Execute the command.n/no: Do nothing and exit.o/open: Open the folder in Explorer and exit.f/file: Opendesktop.iniusing Explorer and exit.
- If no
Targetis configured indesktop.ini, the command simply returns without doing anything. Argsis parsed using whitespace splitting + quotes grouping, with%1/%%expansion.- If Windows returns error code
740(elevation required), it will trigger a UAC prompt and retry viaShellExecuteW.
Batch make folders read-only
desktop-ini sync --path <ROOT> --depth <N>
- Recursively walk from
ROOT. For each directory that containsdesktop.ini, set the folder itself to read-only. --depthcontrols the maximum recursion depth. If omitted, the depth is effectively infinite.- Combine with
--dry-runto see how many folders would be affected without applying changes.
Registry setup
desktop-ini setup
Creates a custom directory class under the current user's registry:
Software\Classes\INI.CustomExecution(name controlled by theDIRECTORY_CLASSconstant).- Sets its
Shell\open\commandto the current executable'srunsubcommand.
Once this is configured, you can use DirectoryClass=INI.CustomExecution plus a [.CustomExecution] section in desktop.ini to have Explorer invoke this program when opening that folder.
Generate shell completions
desktop-ini completion | Out-String | Invoke-Expression
For example, this generates a PowerShell completion script and loads it into the current session. Write this into $PROFILE to make it permanent.
Development
# Run tests
cargo test
# Build the project
cargo build
Main dependencies:
clap/clap_complete: CLI parsing and completionsowo-colors: colored terminal outputencoding_rs: read/write text using the system ANSI code pagethiserror: error type definitionswinreg: Windows registry accesswindows-sys: Windows API calls
Dependencies
~4–16MB
~209K SLoC