2020-07-29 02:23:28 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// WindowsTAP API
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
var SHELL = require("lib/shell");
|
|
|
|
var SYS = require("lib/system");
|
2020-07-29 03:06:49 +00:00
|
|
|
var FILE = require("lib/file");
|
2020-07-29 02:23:28 +00:00
|
|
|
|
|
|
|
exports.VERSIONINFO = "WindowsTAP Lib (wintap.js) version 0.1";
|
|
|
|
exports.global = global;
|
|
|
|
exports.require = global.require;
|
|
|
|
|
2020-07-29 03:06:49 +00:00
|
|
|
exports.infPath = SYS.getEnvString("PROGRAMFILES") + "/TAP-Windows/driver/OemVista.inf";
|
|
|
|
exports.binPath = SYS.getEnvString("PROGRAMFILES") + "/TAP-Windows/bin/tapinstall.exe";
|
|
|
|
|
|
|
|
exports.before = function() {
|
|
|
|
if(!FILE.fileExists(exports.binPath)) {
|
|
|
|
console.log("WindowsTAP dose not installed. Trying to install...");
|
|
|
|
return SHELL.exec(["bin/tap-windows-9.24.2-I601-Win7.exe"]);
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-29 04:17:48 +00:00
|
|
|
/**
|
|
|
|
* @param {string} id
|
|
|
|
*/
|
2020-07-29 03:06:49 +00:00
|
|
|
exports.install = function(id) {
|
|
|
|
exports.before();
|
|
|
|
return SHELL.exec([exports.binPath, "install", exports.infPath, id]);
|
2020-07-29 02:23:28 +00:00
|
|
|
};
|
|
|
|
|
2020-07-29 04:17:48 +00:00
|
|
|
/**
|
|
|
|
* @param {string} id
|
|
|
|
*/
|
2020-07-29 03:06:49 +00:00
|
|
|
exports.update = function(id) {
|
|
|
|
exports.before();
|
|
|
|
return SHELL.exec([exports.binPath, "update", exports.infPath, id]);
|
2020-07-29 02:23:28 +00:00
|
|
|
};
|
|
|
|
|
2020-07-29 04:17:48 +00:00
|
|
|
/**
|
|
|
|
* @param {string} id
|
|
|
|
*/
|
2020-07-29 02:23:28 +00:00
|
|
|
exports.query = function(id) {
|
2020-07-29 03:06:49 +00:00
|
|
|
exports.before();
|
2020-07-29 02:23:28 +00:00
|
|
|
return SHELL.exec([exports.binPath, "hwids", id]);
|
|
|
|
};
|
|
|
|
|
2020-07-29 04:17:48 +00:00
|
|
|
/**
|
|
|
|
* @param {string} id
|
|
|
|
*/
|
2020-07-29 02:23:28 +00:00
|
|
|
exports.remove = function(id) {
|
2020-07-29 03:06:49 +00:00
|
|
|
exports.before();
|
2020-07-29 02:23:28 +00:00
|
|
|
return SHELL.exec([exports.binPath, "remove", id]);
|
|
|
|
};
|