【发布时间】:2018-02-04 16:41:37
【问题描述】:
有什么方法可以解析 Node 中 .lnk 文件中的快捷方式数据(例如,主要是它指向的路径)?
【问题讨论】:
有什么方法可以解析 Node 中 .lnk 文件中的快捷方式数据(例如,主要是它指向的路径)?
【问题讨论】:
如果你使用Electron,它有一个内置方法:
https://www.electronjs.org/docs/api/shell#shellreadshortcutlinkshortcutpath-windows
import { shell } from 'electron';
const parsed = shell.readShortcutLink(shortcutPath);
target String - 从此快捷方式启动的目标。cwd String(可选)- 工作目录。默认为空。args String(可选)- 从该快捷方式启动时应用于目标的参数。默认为空。description String(可选)- 快捷方式的描述。默认为空。icon String(可选)- 图标的路径,可以是 DLL 或 EXE。 icon 和 iconIndex 必须一起设置。默认为空,使用目标的图标。iconIndex Number(可选) - 当图标是 DLL 或 EXE 时图标的资源 ID。默认值为 0。appUserModelId String(可选)- 应用程序用户模型 ID。默认为空。【讨论】:
根据我的评论,Aminadav Glickshtein 的回答对我不起作用,因为所涉及的包在电子项目中存在问题。以下软件包效果更好:
【讨论】:
可以使用npm包windows-shortcuts
https://www.npmjs.com/package/windows-shortcuts
例子:
ws.query("C:/ProgramData/Microsoft/Windows/Start Menu/Windows Update.lnk",
console.log);
/* From console:
null { expanded:
{ args: 'startmenu',
workingDir: 'C:\\Windows\\system32',
icon: 'C:\\Windows\\system32\\wucltux.dll' },
target: '%windir%\\system32\\wuapp.exe',
args: 'startmenu',
workingDir: '%windir%\\system32',
runStyle: 1,
icon: '%windir%\\system32\\wucltux.dll',
iconIndex: '0',
hotkey: 0,
desc: 'Delivers software updates and drivers, and provides automatic updating options.' }
*/
【讨论】: