Fallback to VC registry detection
This commit is contained in:
102
src/helpers.js
102
src/helpers.js
@@ -596,65 +596,65 @@ module.exports.getMissingDependencies = dependencies => {
|
||||
};
|
||||
|
||||
const Registry = require('winreg');
|
||||
const checkRegistry = (dep, index, legacyRuntimeDetection) => {
|
||||
const checkRegistry = (dep, index) => {
|
||||
if (index >= dep.registry.length) {
|
||||
missing.push(dep);
|
||||
resolveIfComplete();
|
||||
} else {
|
||||
if (!legacyRuntimeDetection && (dep.display === 'VC Runtime 2015-2019')) {
|
||||
if (dep.display === 'VC Runtime 2015-2019') {
|
||||
_vcRuntimeExists()
|
||||
.then(exists => {
|
||||
if (exists) {
|
||||
resolveIfComplete();
|
||||
} else {
|
||||
checkRegistry(dep, 0, true);
|
||||
if (!exists) {
|
||||
missing.push(dep);
|
||||
}
|
||||
resolveIfComplete();
|
||||
})
|
||||
.catch (() => {
|
||||
checkRegistry(dep, 0, true);
|
||||
.catch(() => {
|
||||
missing.push(dep);
|
||||
resolveIfComplete();
|
||||
})
|
||||
} else {
|
||||
let hive = null;
|
||||
const hiveName = dep.registry[index].split('\\')[0];
|
||||
switch (hiveName) {
|
||||
case 'HKEY_CLASSES_ROOT':
|
||||
hive = Registry.HKCR;
|
||||
break;
|
||||
case 'HKEY_CURRENT_CONFIG':
|
||||
hive = Registry.HKCC;
|
||||
break;
|
||||
case 'HKEY_CURRENT_USER':
|
||||
hive = Registry.HKCU;
|
||||
break;
|
||||
case 'HKEY_LOCAL_MACHINE':
|
||||
hive = Registry.HKLM;
|
||||
break;
|
||||
case 'HKEY_USERS':
|
||||
hive = Registry.HKU;
|
||||
break;
|
||||
default:
|
||||
throw Error('Invalid registry hive: ' + hiveName);
|
||||
}
|
||||
|
||||
const key = dep.registry[index].substr(hiveName.length);
|
||||
const regKey = new Registry({
|
||||
hive: hive,
|
||||
key: key
|
||||
});
|
||||
regKey.valueExists('DisplayName', (err, exists) => {
|
||||
if (err || !exists) {
|
||||
regKey.valueExists('ProductName', (err, exists) => {
|
||||
if (err || !exists) {
|
||||
checkRegistry(dep, ++index);
|
||||
} else {
|
||||
resolveIfComplete();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resolveIfComplete();
|
||||
}
|
||||
});
|
||||
missing.push(dep);
|
||||
resolveIfComplete();
|
||||
}
|
||||
} else {
|
||||
let hive = null;
|
||||
const hiveName = dep.registry[index].split('\\')[0];
|
||||
switch (hiveName) {
|
||||
case 'HKEY_CLASSES_ROOT':
|
||||
hive = Registry.HKCR;
|
||||
break;
|
||||
case 'HKEY_CURRENT_CONFIG':
|
||||
hive = Registry.HKCC;
|
||||
break;
|
||||
case 'HKEY_CURRENT_USER':
|
||||
hive = Registry.HKCU;
|
||||
break;
|
||||
case 'HKEY_LOCAL_MACHINE':
|
||||
hive = Registry.HKLM;
|
||||
break;
|
||||
case 'HKEY_USERS':
|
||||
hive = Registry.HKU;
|
||||
break;
|
||||
default:
|
||||
throw Error('Invalid registry hive: ' + hiveName);
|
||||
}
|
||||
|
||||
const key = dep.registry[index].substr(hiveName.length);
|
||||
const regKey = new Registry({
|
||||
hive: hive,
|
||||
key: key
|
||||
});
|
||||
regKey.valueExists('DisplayName', (err, exists) => {
|
||||
if (err || !exists) {
|
||||
regKey.valueExists('ProductName', (err, exists) => {
|
||||
if (err || !exists) {
|
||||
checkRegistry(dep, ++index);
|
||||
} else {
|
||||
resolveIfComplete();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resolveIfComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user