systeminformation icon indicating copy to clipboard operation
systeminformation copied to clipboard

Hey Whay don't have support for installed softwares....

Open artemis15 opened this issue 5 years ago • 18 comments

artemis15 avatar Nov 16 '19 05:11 artemis15

I've create another script file for the same. If you want i can send it over and you can put a new version.

artemis15 avatar Nov 20 '19 02:11 artemis15

@artemis15 ... if you have something in mind or even some sample code, would be great to have a look at it.

sebhildebrandt avatar Nov 20 '19 06:11 sebhildebrandt

hey, I'm thinking to become contributer to the discovery of installed software. Do let me know if that's okay with you.

artemis15 avatar Dec 30 '20 06:12 artemis15

@artemis15 hello Akash, thank you for your feature request. Back then last year I also spend some time on trying to provide a solution here. I guess we should clarify some questions:

What exactly is "installed software" - for Windows and Mac OS this might be clear (I have a solution in place already) but on linux this is not that clear. Here we have to handle quite a lot package managers to get valid lists across different distributions.

What exactly are you thinking of?

sebhildebrandt avatar Dec 31 '20 09:12 sebhildebrandt

Hey,

Wishing you a very happy new year.

Yes win and Mac can be done but there is a catch with win and Mac that you need admin access to get installed softwares.

Regarding Linux, I've some scripts that I'm using to get data( I've been using it for last 1.5 yrs and it's giving good result.)

Probably, we can spend some time and discuss on it.

-- Cheers, Ar

On Thu, Dec 31, 2020, 3:14 PM Sebastian Hildebrandt < [email protected]> wrote:

@artemis15 https://github.com/artemis15 hello Akash, thank you for your feature request. Back then last year I also spend some time on trying to provide a solution here. I guess we should clarify some questions:

What exactly is "installed software" - for Windows and Mac OS this might be clear (I have a solution in place already) but on linux this is not that clear. Here we have to handle quite a lot package managers to get valid lists across different distributions.

What exactly are you thinking of?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sebhildebrandt/systeminformation/issues/296#issuecomment-752905195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB57KEGCKH6K5WEPRVVGFDTSXRBXFANCNFSM4JODQBFA .

artemis15 avatar Jan 01 '21 03:01 artemis15

@artemis15 I will add some initial code for this in version 5 which I am already working on. If you have partial scripts e.g. for linux, maybe you want to create a gist on your side and provide a link? I will then think of how this can be integrated to systeminformation.

sebhildebrandt avatar Jan 06 '21 07:01 sebhildebrandt

Sure..will do that

artemis15 avatar Jan 06 '21 07:01 artemis15

@artemis15 thank you so much. I am sure, this will be a quite nice enhancement for the package!

sebhildebrandt avatar Jan 06 '21 07:01 sebhildebrandt

yes it will be

On Wed, Jan 6, 2021 at 1:04 PM Sebastian Hildebrandt < [email protected]> wrote:

@artemis15 https://github.com/artemis15 thank you so much. I am sure, this will be a quite nice enhancement for the package!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sebhildebrandt/systeminformation/issues/296#issuecomment-755136930, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB57KEDNFDHBRZERBTHC3IDSYQG7JANCNFSM4JODQBFA .

--

Akash Rajput

Tel: (+91) 9999033473 [email protected]

skype: akash.rajput15

artemis15 avatar Jan 06 '21 09:01 artemis15

@artemis15 did you end up creating the gist?

OmgImAlexis avatar Oct 25 '21 07:10 OmgImAlexis

Yes win and Mac can be done but there is a catch with win and Mac that you need admin access to get installed softwares.

What makes you say this? This works on macos to get all the installed apps.

system_profiler SPApplicationsDataType

https://apple.stackexchange.com/a/129854/130438

OmgImAlexis avatar Oct 27 '21 20:10 OmgImAlexis

Also this works in windows without admin.

$loc = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall

$names = $loc |foreach-object {Get-ItemProperty $_.PsPath}

foreach ($name in $names)
{
    Write-Host $name.Displayname
}

https://superuser.com/a/68616/297973

OmgImAlexis avatar Oct 27 '21 20:10 OmgImAlexis

Hey, this windows script do not give you all details. And it's because of windows arch. you can use below script to find out running softwares. winHelper.txt

Also, in many windows system, this script will require admin access [I've tried it in near 100 different servers]

artemis15 avatar Oct 29 '21 03:10 artemis15

@artemis15 unless you can show ones missing I'm inclined to not believe that.

The code I provided above doesn't require admin and does in fact show all apps installed.

OmgImAlexis avatar Oct 29 '21 06:10 OmgImAlexis

Actually looking at your code it does the same thing but in a more hacky way.

OmgImAlexis avatar Oct 29 '21 06:10 OmgImAlexis

Hi @sebhildebrandt , I've create software gist. You can use it for Mac and Win server details. Will share Linux one later:

https://gist.github.com/artemis15/2f97e35d89087baae4ae8fee3eae43b4

above gist uses winhelper.js for windows: gist for windows: https://gist.github.com/artemis15/6a17a2543403e85ba0a128c3571ae64a

artemis15 avatar Oct 29 '21 07:10 artemis15

Here's a version of the first gist that's a bit more readable.

const { exec, execSync } = require('child_process');

const MAX_BUFFER_SIZE = 1024 * 5000;

const getQueries = () => {
    if (process.arch === 'x64') {
        return [
            `${getWindowsCommandPath()}\\REG QUERY HKLM\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ /s`,
            `${getWindowsCommandPath()}\\REG QUERY HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ /s`
        ];
    }

    return [
        `${getWindowsCommandPath()}\\REG QUERY HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ /s`,
    ];
};

const getWindowsCommandPath = () => {
    if (process.arch === 'ia32' && process.env.PROCESSOR_ARCHITEW6432) {
        return '%windir%\\sysnative\\cmd.exe /c %windir%\\System32';
    }

    return '%windir%\\System32';
};

const getAllInstalledSoftware = async () => {
    const queries = getQueries();
    const results = Promise.all(queries.map(query => new Promise((resolve, reject) => {
        exec(query, { maxBuffer: MAX_BUFFER_SIZE },
            (error, stdout, stderr) => {
                if (error) {
                    return reject(stderr.toString());
                }

                resolve(stdout.toString());
            }
        );
    })));
    const fullList = results
        .slice(1)
        .reduce((accumulatingList, queryResult) => `${accumulatingList}${queryResult.trimRight()}`, results[0].trim());

    return processCmdOutput(fullList);
};

const getAllInstalledSoftwareSync = () => {
    const results = getQueries().map((queryString) => execSync(queryString).toString());
    const fullList = results
        .slice(1)
        .reduce((accumulatingList, queryResult) => `${accumulatingList}${queryResult.trimRight()}`, results[0].trim());
    return processCmdOutput(fullList);
};

const processCmdOutput = (fullList) => {
    const softwareList = [];
    fullList
        .split(/^HKEY_LOCAL_MACHINE/m)
        .shift()
        .forEach((softwareBlock) => {
            const softwareObject = {};
            let lastKey = '';
            let lastValue = '';

            const softwareLines = softwareBlock.split(/\r?\n/);
            softwareObject['RegistryDirName'] = softwareLines
                .shift()
                .match(/^(\\[^\\]+)*?\\([^\\]+)\s*$/)[2];
            softwareLines.forEach((infoLine) => {
                if (infoLine.trim()) {
                    let infoTokens = infoLine.match(/^\s+(.+?)\s+REG_[^ ]+\s*(.*)/);
                    if (infoTokens) {
                        infoTokens = infoTokens.removeFirst();
                        lastKey = infoTokens[0];
                        lastValue = infoTokens[1];
                    } else {
                        lastValue = lastValue + '\n' + infoLine;
                    }
                    softwareObject[lastKey] = lastValue;
                }
            });
            softwareList.push(softwareObject);
        });
    return softwareList;
};

module.exports = {
    getAllInstalledSoftwareSync: getAllInstalledSoftwareSync,
    getAllInstalledSoftware: getAllInstalledSoftware,
};

OmgImAlexis avatar Oct 29 '21 10:10 OmgImAlexis

This type of thing should never be done.

Array.prototype.removeFirst = function () {
  this.shift();
  return this;
};

OmgImAlexis avatar Oct 29 '21 10:10 OmgImAlexis