Closed hl-a-k closed 4 years ago
I also encountered this problem, I don't know how to solve it.
Instead of HKEY_LOCAL_MACHINE
, use HKLM
.
这么写会报错
regedit.list('HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run', (err, data) => {
if (err) {
console.log(err);
}
console.log('data: ', data);
});
HKEY_CURRENT_USER
简写为 HKCU
, 改成下面的写法就可以了
regedit.list('HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run', (err, data) => {
if (err) {
console.log(err);
}
console.log('data: ', data);
});
"vue-cli-plugin-electron-builder": "^1.4.6",
// vue.config.js
module.exports = {
pluginOptions: {
electronBuilder: {
extraResources: [
{
from: 'node_modules/regedit/vbs',
to: 'vbs',
filter: ['**/*']
}
],
}
}
}
// setRegedit.js
import path from 'path';
import electron from 'electron';
import regedit from 'regedit';
export function setExternalVBSLocation() {
// 打包时vbs 单独抽离出来,一起打包regedit会读取不了
// 官网地址:https://github.com/ironSource/node-regedit
// Assuming the files lie in <app>/resources/my-location
const vbsDirectory = path.join(path.dirname(electron.remote.app.getPath('exe')), './resources/vbs');
regedit.setExternalVBSLocation(vbsDirectory);
}
export default function setRegedit() {
setExternalVBSLocation();
// HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run
// HKCU === HKEY_CURRENT_USER (当前用户sid)
// 为什么是HKCU?因为regedit不支持HKEY_CURRENT_USER开头的形式,具体请看下面的issues链接
// https://github.com/ironSource/node-regedit/issues/62
regedit.list('HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run', (err, data) => {
if (err) {
console.log(err);
}
console.log('data: ', data);
})
}
I need know path of chrome.exe, here is my code:
And I get
My machine is windows 10.