I am trying to transform an HTA to an Electron App, and I am having some issues in getting the version of a program by the installer product name.
So my working VBS portion of code is:
varProgram1 = "NotFound" : varProgram2 = "NotFound" : varProgram3 = "NotFound"
Set objInstaller = CreateObject("WindowsInstaller.Installer")
Set colProducts = objInstaller.Products
For Each objProduct In colProducts
strProductName = objInstaller.ProductInfo(objProduct, "ProductName")
If strProductName = "Program1_Name" Then
varProgram1 = objInstaller.ProductInfo(objProduct, "VersionString")
End If
If strProductName = "Program2_Name" Then
varProgram2 = objInstaller.ProductInfo(objProduct, "VersionString")
End If
If strProductName = "Program3_Name" Then
varProgram3 = objInstaller.ProductInfo(objProduct, "VersionString")
End If
Next
The code works, and is fast also because I go directly to the product name. Now in Javascript I don't know exactly how to do this. I do have a version where I search for an exe and msi, but it is slow and also doesn't find the actual product name in the installer.
window.getFile = (event) => {
const fileName = event.target.name
const filePath = pathList[parseInt(event.target.getAttribute("path"))]
const fullUrl = `file:///${defaultPath}${fileName}`
if (fileName.includes(".exe") || fileName.includes(".msi")) {
const a = document.createElement('a')
a.href = fullUrl
console.log(fullUrl)
a.download = fileName
document.body.appendChild(a)
a.click()
} else {
const options = {
name: 'Electron',
icns: '/'
};
async function Move() {
try {
await sudo.exec(`copy "${defaultPath}\\${fileName}" "${filePath.replace(fileName, "")}"`, options)
return "Done"
} catch (error) {
alert(error)
}
return "done"
}
Move().then(data => window.location.reload(true))
}
}
Any help on how to search the windows installer for a product name an return it's version using electron and js would be much appreciated. Thanks!