welsonjs/bootstrap.js

71 lines
2.6 KiB
JavaScript
Raw Normal View History

2020-07-21 06:14:14 +00:00
//////////////////////////////////////////////////////////////////////////////////
//
// bootstrap.js
//
/////////////////////////////////////////////////////////////////////////////////
2022-04-28 04:11:26 +00:00
var STD = require("lib/std");
2020-07-21 06:14:14 +00:00
var PS = require("lib/powershell");
var REG = require("lib/registry");
2020-07-21 06:30:18 +00:00
var SYS = require("lib/system");
var SHELL = require("lib/shell");
2020-07-21 06:14:14 +00:00
2020-11-04 07:30:52 +00:00
var appName = "welsonjs";
2023-01-03 07:35:53 +00:00
var isDisabledRegisterURIScheme = false;
2020-11-04 07:30:52 +00:00
2020-07-27 02:31:52 +00:00
exports.main = function(args) {
// unlock file
console.log("Starting unlock files...");
PS.execCommand("dir | Unblock-File");
2020-07-21 06:14:14 +00:00
2020-07-27 02:31:52 +00:00
// Allow CROS to ADO
2022-04-20 03:33:07 +00:00
//console.log("Adjusting CROS policy to ADO...");
//REG.write(REG.HKCU, "SOFTWARE\\Policies\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Lockdown_Zones\\4", "1406", "00000000", REG.DWORD);
//REG.write(REG.HKLM, "SOFTWARE\\Policies\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Lockdown_Zones\\4", "1406", "00000000", REG.DWORD);
2020-07-21 06:14:14 +00:00
2021-12-09 07:51:53 +00:00
// Register HTA file association
console.log("Registering HTA file association...");
2024-07-22 19:26:38 +00:00
REG.execFile("app\\assets\\reg\\Default_HTA.reg");
2021-12-09 07:51:53 +00:00
// Register URI scheme
2023-01-03 07:35:53 +00:00
if (!isDisabledRegisterURIScheme) {
console.log("Registering URI scheme...");
REG.write(REG.HKCR, appName, "", "URL:" + appName, REG.STRING);
REG.write(REG.HKCR, appName, "URL Protocol", "", REG.STRING);
REG.write(REG.HKCR, appName + "\\DefaultIcon", "", SYS.getCurrentScriptDirectory() + "\\app\\favicon.ico,0", REG.STRING);
REG.write(REG.HKCR, appName + "\\shell\\open\\command", "", "cmd.exe /c cscript " + SYS.getCurrentScriptDirectory() + "\\app.js uriloader \"%1\"", REG.STRING);
} else {
console.log("Skipped register URI scheme");
}
2020-07-21 06:14:14 +00:00
2020-11-18 04:13:38 +00:00
// open web application
2020-07-27 02:31:52 +00:00
console.log("Trying open GUI...");
2020-11-18 04:13:38 +00:00
// detect old process
var processList = SYS.getProcessList();
for (var i = 0; i < processList.length; i++) {
2020-12-07 03:48:37 +00:00
try {
var process = processList[i];
if (process.Caption == "mshta.exe") {
2022-04-28 04:11:26 +00:00
//console.warn("Will be kill process ID:", process.ProcessID);
//SYS.killProcess(process.ProcessID);
//sleep(1000);
STD.alert("Please close the running application (PID: " + process.processID + ")");
return 0;
2020-12-07 03:48:37 +00:00
}
2021-04-28 07:28:43 +00:00
} catch (e) {
console.warn(e.message);
}
2020-11-18 04:13:38 +00:00
}
2022-04-20 03:33:07 +00:00
// Opening HTML application
if (typeof args !== "undefined") {
2020-07-27 02:31:52 +00:00
SHELL.run(["app.hta"].concat(args));
} else {
SHELL.run("app.hta");
2020-07-21 06:14:14 +00:00
}
2020-07-27 02:31:52 +00:00
2022-04-20 03:33:07 +00:00
// print welcome
2020-07-27 02:31:52 +00:00
console.log("welcome");
2020-11-04 07:30:52 +00:00
};