forked from PhoenicisOrg/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
72 lines (62 loc) · 2.23 KB
/
script.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
71
72
const Wine = include("engines.wine.engine.object");
include("engines.wine.plugins.regedit");
/**
* default windows version
* @param {string} version (win7, vista, win2003, winxp, win2k, winnt, winme, win98, win95, win31)
* @param {string} [servicePack] e.g. sp3
* @returns {string|Wine} get: Windows version, set: Wine object
*/
Wine.prototype.windowsVersion = function (version, servicePack) {
var that = this;
// get
if (arguments.length == 0) {
return this.regedit().fetchValue(["HKEY_CURRENT_USER", "Software", "Wine", "Version"]);
}
// set
var regeditFileContent;
if (version == null) {
regeditFileContent =
"REGEDIT4\n" +
"\n" +
"[HKEY_CURRENT_USER\\Software\\Wine]\n" +
"\"Version\"=-\n";
} else {
regeditFileContent =
"REGEDIT4\n" +
"\n" +
"[HKEY_CURRENT_USER\\Software\\Wine]\n" +
"\"Version\"=\"" + version + "\"\n";
if (servicePack) {
var servicePackNumber = servicePack.replace("sp", "");
regeditFileContent += "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion]\n";
regeditFileContent += "\"CSDVersion\"=\"Service Pack " + servicePackNumber + "\"\n";
regeditFileContent += "[HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Windows]\n";
regeditFileContent += "\"CSDVersion\"=dword:00000" + servicePackNumber + "00\n";
}
}
this.regedit().patch(regeditFileContent);
return this;
};
var SetOsForApplication = function () {
var that = this;
that._regeditFileContent =
"REGEDIT4\n" +
"\n";
that.wine = function (wine) {
that._wine = wine;
return that;
};
that.set = function (application, os) {
that._regeditFileContent += "[HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" + application + "]\n";
that._regeditFileContent += "\"Version\"=\"" + os + "\"\n";
return that;
};
that.do = function () {
that._wine.regedit().patch(that._regeditFileContent);
return that._wine;
}
};
Wine.prototype.setOsForApplication = function () {
return new SetOsForApplication()
.wine(this)
};