Added Uninstall/MetaData check for windows
Bryan Roe committed
Jan 6, 2020 at 11:00 UTC
be2b52432e840061db256d9b5ab124787b112de2
1 file changed
+23
agents/meshcore.js
+23
@@ -39,6 +39,29 @@ var MESHRIGHT_LIMITEDINPUT = 4096;
39
40
function createMeshCore(agent) {
41
var obj = {};
42
+ if (process.platform == 'win32' && require('user-sessions').isRoot())
43
+ {
44
+ // Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
45
+ var actualSize = require('fs').statSync(process.execPath).size / 1024;
46
+ var writtenSize = 0;
47
+ try
48
+ {
49
+ writtenSize = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent', 'EstimatedSize');
50
+ }
51
+ catch(x)
52
+ {
53
+ }
54
+ if (writtenSize != actualSize)
55
+ {
56
+ try
57
+ {
58
+ require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent', 'EstimatedSize', actualSize);
59
+ }
60
+ catch (x2)
61
+ {
62
+ }
63
+ }
64
+ }
65
66
if (process.platform == 'darwin' && !process.versions) {
67
// This is an older MacOS Agent, so we'll need to check the service definition so that Auto-Update will function correctly