【问题标题】:how to get exe files using fs.readdirsync() in electron js如何在电子 js 中使用 fs.readdirsync() 获取 exe 文件
【发布时间】:2020-04-21 22:38:14
【问题描述】:

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

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

如何只获取exe文件

【问题讨论】:

  • 系统中安装的应用程序还是目录中存在的exe文件?
  • 已安装应用.EX游戏应用

标签: node.js electron fs


【解决方案1】:

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

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

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

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

【讨论】:

  • execSync('wmic product get name,version'); ?我们在这里给出的内容..我想列出 windows 中的所有 exe 文件。在你的代码列表中什么都没有显示
  • 我们可以从这个列表中启动一些应用程序吗.. 动态地使用 execFile()
猜你喜欢
  • 2017-08-29
  • 2020-06-07
  • 1970-01-01
  • 2020-12-02
  • 2011-01-14
  • 1970-01-01
  • 2020-07-04
  • 2021-08-27
相关资源
最近更新 更多