Path: blob/master/test/jdk/tools/jpackage/resources/query-msi-property.js
41149 views
/*1* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/222324function readMsi(msiPath, callback) {25var installer = new ActiveXObject('WindowsInstaller.Installer')26var database = installer.OpenDatabase(msiPath, 0 /* msiOpenDatabaseModeReadOnly */)2728return callback(database)29}303132function queryAllProperties(db) {33var reply = {}3435var view = db.OpenView("SELECT `Property`, `Value` FROM Property")36view.Execute()3738try {39while(true) {40var record = view.Fetch()41if (!record) {42break43}4445var name = record.StringData(1)46var value = record.StringData(2)4748reply[name] = value49}50} finally {51view.Close()52}5354return reply55}565758(function () {59var msi = WScript.arguments(0)60var propName = WScript.arguments(1)6162var props = readMsi(msi, queryAllProperties)63WScript.Echo(props[propName])64})()656667