diff --git a/lib/ovftool.js b/lib/ovftool.js index 8ceb564..31a2b8d 100644 --- a/lib/ovftool.js +++ b/lib/ovftool.js @@ -6,35 +6,42 @@ var SHELL = require("lib/shell"); var CRED = require("lib/credentials"); function OVFObject() { - this.binPath = "bin/x64/VMware-ovftool-4.6.3-24031167-win.x86_64/ovftool/ovftool.exe"; + this.binPath = "bin\\x64\\VMware-ovftool-4.6.3-24031167-win.x86_64\\ovftool\\ovftool.exe"; this.hostname = ""; + this.port = 443; this.resourceName = ""; this.setBinPath = function(binPath) { this.binPath = binPath; }; - this.setHostname = function(hostname) { + this.setHostName = function(hostname) { this.hostname = hostname; }; + + this.setPort = function(port) { + this.port = port; + }; this.setResourceName = function(resourceName) { this.resourceName = resourceName; }; - this.saveTo = function() { + this.saveTo = function(filename) { var cred = CRED.get("password", "ovftool"); var connectionString = "vi://" + - cred.username + ":" + + encodeURIComponent(cred.username) + ":" + encodeURIComponent(cred.password) + "@" + - this.hostname + "/" + + this.hostname + (this.port == 443 ? "" : ":" + this.port) + this.resourceName ; var cmd = [ this.binPath, connectionString, - "." + filename ]; + + console.log("connectionString:", connectionString); // run the command synchronously SHELL.show(cmd, false); @@ -43,9 +50,8 @@ function OVFObject() { function setCredential(username, password) { CRED.push("password", "ovftool", { - "hostname": hostname, "username": username, - "password": password, + "password": password }); } @@ -56,7 +62,7 @@ function create() { exports.setCredential = setCredential; exports.create = create; -exports.VERSIONINFO = "Broadcom/VMware OVF Tool interface (ovftool.js) version 0.1.1"; +exports.VERSIONINFO = "Broadcom/VMware OVF Tool interface (ovftool.js) version 0.1.2"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require; diff --git a/lib/shell.js b/lib/shell.js index 69f395a..1b6075b 100644 --- a/lib/shell.js +++ b/lib/shell.js @@ -146,18 +146,26 @@ var ShellObject = function() { this.run = function(cmd, fork) { var fork = (typeof(fork) !== "undefined") ? fork : true; var c = "%comspec% /q /c (" + this.build(cmd) + ")"; + var windowStyle = (this.visibility === "hidden" ? 0 : 1); console.log("ShellObject.run() ->", c); - this._interface.Run(c, (this.visibility === "hidden" ? 0 : 1), !fork); + if (windowStyle == 1) { + console.log("Will be open the visible window"); + } + this._interface.Run(c, windowStyle, !fork); }; this.runAs = function(FN, args) { var oShell = CreateObject("Shell.Application"); + var windowStyle = (this.visibility === "hidden" ? 0 : 1); var _args = null; console.log("ShellObject.runAs() ->", FN); if (typeof(args) !== "undefined") { _args = args.join(' '); } - oShell.shellExecute(FN, _args, this.workingDirectory, "runas", (this.visibility === "hidden" ? 0 : 1)); + if (windowStyle == 1) { + console.log("Will be open the visible window"); + } + oShell.shellExecute(FN, _args, this.workingDirectory, "runas", windowStyle); return oShell; }; @@ -246,7 +254,7 @@ exports.getPathOfMyDocuments = function() { exports.CdoCharset = PipeIPC.CdoCharset; -exports.VERSIONINFO = "Windows Shell Interface (shell.js) version 0.3.17"; +exports.VERSIONINFO = "Windows Shell Interface (shell.js) version 0.3.18"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require;