node.js - 如何在 Electron js 中使用 fs.readdirsync() 获取 exe 文件

标签 node.js electron fs

我想在 Electron js 桌面应用程序中获取 exe 或桌面应用程序(安装的本地 PC)的列表。我尝试了 require('fs') 但它只列出了根路径中的文件夹。

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

如何只获取exe文件

最佳答案

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

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

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

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

关于node.js - 如何在 Electron js 中使用 fs.readdirsync() 获取 exe 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59577311/

相关文章:

javascript - 在 NodeJS 中读取 JSON 属性?

node.js - 为什么 Mikro-orm 将数字作为字符串发送回来?

node.js - Electron App 打包后没有运行

angularjs - 将本地 Node JS HTTP 服务器端口(在 Electron 中运行)传递给 angular.service

node.js - Electron Js : Unable to install using . msi 因为路径太长

javascript - 如何在模块中使用变量(登录系统)

javascript - 使用 node.js 从文件中返回搜索文本的行

node.js - Sequelize : Object true has no method 'init'

node.js - 如何使用 Mongoose 获取 MongoDB 集合的大小(字节)?

node.js - NodeJS : Confusion about async "readdir" and "stat"