2021-12-13 08:11:10 +00:00
|
|
|
const fs = require('fs');
|
2022-12-02 22:23:46 +00:00
|
|
|
const { join, resolve } = require('path');
|
2022-03-10 08:46:09 +00:00
|
|
|
|
2022-04-27 20:54:08 +00:00
|
|
|
const Constants = require('./Constants');
|
2022-04-30 11:13:49 +00:00
|
|
|
const reg = (a, c) => require('child_process').execFile('reg.exe', a, c);
|
2021-12-13 08:11:10 +00:00
|
|
|
|
2022-04-12 17:18:47 +00:00
|
|
|
const exec = process.execPath;
|
|
|
|
const app = resolve(exec, '..');
|
2021-12-13 08:11:10 +00:00
|
|
|
|
|
|
|
|
2022-12-02 22:23:46 +00:00
|
|
|
exports.do = () => {
|
2022-04-12 17:12:42 +00:00
|
|
|
const flag = join(app, '.first-run');
|
2022-03-25 22:54:40 +00:00
|
|
|
if (fs.existsSync(flag)) return; // Already done, skip
|
2021-12-13 08:11:10 +00:00
|
|
|
|
2022-04-12 17:12:42 +00:00
|
|
|
const proto = Constants.APP_PROTOCOL;
|
|
|
|
const base = 'HKCU\\Software\\Classes\\' + proto;
|
|
|
|
|
2022-04-29 22:15:34 +00:00
|
|
|
for (const x of [
|
2022-04-30 11:06:27 +00:00
|
|
|
[base, '/ve', '/d', `URL:${proto} Protocol`],
|
|
|
|
[base, '/v', 'URL Protocol'],
|
2022-04-29 22:15:34 +00:00
|
|
|
[base + '\\DefaultIcon', '/ve', '/d', `"${exec}",-1`],
|
|
|
|
[base + '\\shell\\open\\command', '/ve', '/d', `"${exec}" --url -- "%1"`]
|
|
|
|
]) reg([ 'add', ...x, '/f' ], e => {});
|
|
|
|
|
2022-12-02 22:23:46 +00:00
|
|
|
try {
|
|
|
|
fs.writeFileSync(flag, '');
|
2022-04-29 22:15:34 +00:00
|
|
|
} catch (e) {
|
|
|
|
log('FirstRun', e);
|
|
|
|
}
|
2022-01-29 11:12:39 +00:00
|
|
|
};
|