我想在 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/