-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
bootstrap.js
70 lines (60 loc) · 2.56 KB
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//////////////////////////////////////////////////////////////////////////////////
//
// bootstrap.js
//
/////////////////////////////////////////////////////////////////////////////////
var STD = require("lib/std");
var PS = require("lib/powershell");
var REG = require("lib/registry");
var SYS = require("lib/system");
var SHELL = require("lib/shell");
var appName = "welsonjs";
var isDisabledRegisterURIScheme = false;
exports.main = function(args) {
// unlock file
console.log("Starting unlock files...");
PS.execCommand("dir | Unblock-File");
// Allow CROS to ADO
//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);
// Register HTA file association
console.log("Registering HTA file association...");
REG.execFile("app\\assets\\reg\\Default_HTA.reg");
// Register URI scheme
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");
}
// open web application
console.log("Trying open GUI...");
// detect old process
var processList = SYS.getProcessList();
for (var i = 0; i < processList.length; i++) {
try {
var process = processList[i];
if (process.Caption == "mshta.exe") {
//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;
}
} catch (e) {
console.warn(e.message);
}
}
// Opening HTML application
if (typeof args !== "undefined") {
SHELL.run(["app.hta"].concat(args));
} else {
SHELL.run("app.hta");
}
// print welcome
console.log("welcome");
};