installed-win-apps
Version:
Get the paths of installed programs on Windows
65 lines (40 loc) • 2.89 kB
Markdown
## installed-win-apps
returns the paths of all installed apps on Windows
**Update 1.1.7**: Fixed: Ignore lnk folders in start menu which I do not have permission to read.
**Update 1.1.6**: Fixed: output incorrect targets when running 32bit node on 64 bit Windows
**Update 1.1.4**: Added: output lnk files only and do not extract targets. It's much faster way to check if an app is installed.
**Update 1.1.3**: Bug fixed: not working when script path includes spaces. (a bug with npm win-lnk-parser)
**Update 1.1.1**: You can filter installed paths by passing a keyword as argument
**Update 1.0.8**: Fixed a bug with win-codepage module as it won't work on non-English Windows
**Why**: I could not use the existing modules to get the path of certain programs like WPS
**How**: Read start menu folders recursively for shortcut files (.lnk) and get the path information.
**Who am I**: Developer of GT4T [gt4t.net](https://gt4t.net), a file translator app that translates Office, Markdown, PDF, HTML files in batches. No file upload needed.
## installation
```
npm i installed-win-apps
```
## Usage
```
const installedPaths = require ('installed-win-apps');
installedPaths.getAllPaths().then (paths=>{
console.log(paths) //paths is an array that contains the paths of all installed apps. e.g. [{lnk: "file file path.lnk", target: "target exe path.exe"}]
})
//Check if Microsoft Word is installed; returns an array if found and false if not found;
installedPaths.getAllPaths("Microsoft Word").then (paths=>{
console.log(paths) //paths is an array that contains the paths of all installed apps with name containing "Microsoft Word". e.g. [{lnk: "file file path.lnk", target: "target exe path.exe"}]
})
installedPaths.getAllPaths("no such an app!").then (paths=>{
console.log(paths) //false
})
installedPaths.getAllPaths("Microsoft Word", true).then (paths=>{
// Second parameter true means prints out lnk files only and do not extract target for faster performance
console.log(paths) //paths is an array that contains the paths of all installed apps with name containing "Microsoft Word". e.g. [{lnk: "file file path.lnk", target: ""}]
})
```
## Functions
`async getAllPaths(keyword = "", lnkOnly=false)`
* @param {String} keyword @default {empty string}: Filter for an application. Print out all applications when left empty.
* @param {Boolean} lnkOnly @default {false}: Print out lnk files only. Do not extract targets. Fast way to find out if an application is installed.
* @returns {Array} Array of objects {lnk: "", target: ""} . e.g. [{lnk: "PATH/myapp.lnk", target: "PATH/myapp.exe"},{lnk: "PATH/yourapp.lnk", target: "PATH/yourapp.exe"}]
## Caveats
- Implementation only currently supports Windows systems