使用Electron JS中的`fs.readdirsync()`如何获取exe文件。

huangapple go评论58阅读模式
英文:

how to get exe files using fs.readdirsync() in electron js

问题

如何仅获取exe文件。

英文:

I want to get the list of exe or desktop application(installed local PC) in electron js desktop application.I tried require('fs') but it list only folder from root path.

const fs = require('fs');
const root = fs.readdirSync('/')
console.log(root);

how to get only exe file

答案1

得分: 1

在Windows上的一个简单方法。可能需要一些时间来检索列表。

const { execSync } = require('child_process');

let list = execSync('wmic product get name,version');
console.log(list.toString());

最好的方法是编写一个使用N-API的本机Node模块来执行此操作。

英文:

A simple way on Windows. Might take some time to retrieve the list.

const { execSync } = require('child_process');

let list = execSync('wmic product get name,version');
console.log(list.toString());

The best way would be writing a native node module using N-API to do this.

huangapple
  • 本文由 发表于 2020年1月3日 18:56:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/59577311.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定