0.1.0 • Published 4 years ago
@josephuspaye/show-properties v0.1.0
show-properties
A Node.js module for showing the File Explorer properties dialog for a file or folder on Windows.
This project is part of #CreateWeekly, my attempt to create something new publicly every week in 2020.
Why
It's easy to call ShellExecuteEx with the properties
verb to show the properties dialog. What's hard is keeping the dialog open without blocking or using hacks like Sleep()
. This module solves that problem using a custom executable and a wrapping Node module.
Installation
npm install @josephuspaye/show-properties --save
Usage
const { showProperties } = require('@josephuspaye/show-properties');
// Show the properties dialog for the default local disk
showProperties('C:\\');
// Show the properties dialog for a file
showProperties('C:\\my-file.txt');
// Show the properties dialog for a folder
showProperties('C:\\my-folder');
API
/**
* Show the Explorer properties dialog for the file or folder at the given path.
* Returns the exit code of the launcher process (not the launched dialog process).
*/
function showProperties(targetPath: string): Promise<number | null>;
Building the executable
The module uses an executable to launch the properties dialog for the given path. The source of this executable is at src/show-properties.cpp and you can build it as follows:
- Install an MSVC Compiler. You can get this with windows-build-tools or Visual Studio.
- Copy the
.env.bat.example
file to.env.bat
and update the variables to match your system - Run
./build.bat
to build. The resulting executable will be placed atbin/ShowProperties.exe
.
Licence
0.1.0
4 years ago