Old 21st September 2022, 16:14   #1
Mike-Sean
Junior Member
 
Join Date: Sep 2022
Posts: 7
Processor, Memory, OS, SSD and TPM information

Hi,

I am trying to create an installer that checks to see if the current hardware meets minimum system requirements.
In order to do this I need to processor, total physical RAM, operating system version and also mainly SSD and TPM information.

I have searched the forums but i haven't found a function that will give me this information's like SSD and TPM

Does anyone have any idea how i might accomplish this using NSIS script?
Mike-Sean is offline   Reply With Quote
Old 21st September 2022, 16:23   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,541
https://nsis.sourceforge.io/HwInfo_plug-in and http://forums.winamp.com/showthread.php?threadid=139639 should get you started.

WinVer.nsh for the Windows version.

SSD might need WMI or something like that. I have no clue about TPM but if the software you are installing uses the TPM then I'm sure you know which API to call...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th September 2022, 15:46   #3
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 558
Quote:
Originally Posted by Mike-Sean View Post
In order to do this I need to processor, total physical RAM, operating system version and also mainly SSD and TPM information.
What do you need?

- CPU Name, Speed?
- Total RAM
- OS Name, Version
- SSD -> What info? Name, size, type?
- TPM -> Active or Not?

Most of that info can be easily gathered.
As far as I know, TPM info can be obtained using WMI (Win32_TPM class)

Ps: Maybe I will create simple plugin that show such info... need to find time and I wonder if there are more people that would like to see such plugin for NSIS
-Pawel
Pawel is offline   Reply With Quote
Old 25th September 2022, 20:03   #4
Mike-Sean
Junior Member
 
Join Date: Sep 2022
Posts: 7
Hi Thanks for your reply.

Yes i need a plugin which gives all these information like :
- CPU Name
- Total RAM - In GB
- OS Name, Version
- SSD -> Need Name of the SSD and Type
- TPM -> Need Active or not and type or Name of TPM.

It would be great if you provide me this plugin information.
Mike-Sean is offline   Reply With Quote
Old 26th September 2022, 10:29   #5
Mike-Sean
Junior Member
 
Join Date: Sep 2022
Posts: 7
And i have added the below powershell script to get the SSD info:
ForEach ($disk in (Get-PhysicalDisk | Select-Object FriendlyName, MediaType)){
If ($disk.MediaType -eq 'SSD'){
$SSDName = $disk.FriendlyName
Write-host "SSD name " : $SSDName
break
}
}

This script i called from my .nsi script but how do i get the actual output from powershell to nsi script and get displayed?
Mike-Sean is offline   Reply With Quote
Old 26th September 2022, 16:36   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,541
The nsExec plug-in can catch stdout strings.

Alternatively you can write it to a .ini in $pluginsdir. Make PS output something like
Quote:
[ssd]
0=name1here
1=name2here
and use the NSIS ini functions to read 0..N-1

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th September 2022, 16:50   #7
Mike-Sean
Junior Member
 
Join Date: Sep 2022
Posts: 7
I have written Nsis script like below:
Push $R0
nsExec::ExecToStack 'powershell -inputformat none -ExecutionPolicy RemoteSigned -File ""$EXEDIR\GetHWInfo1.ps1""'
Pop $R0

${If} $R0 == '0'
MessageBox MB_OK "SSD exists"
${Else}
MessageBox MB_OK " SSD not exists"
${EndIf}

Is this correct?
Mike-Sean is offline   Reply With Quote
Old 26th September 2022, 18:00   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,541
I don't know what your script looks like but you are checking the powershell.exe exit code and you are missing a pop.

PHP Code:
Section 
nsExec
::ExecToStack '"$sysdir\cmd.exe" /C echo Hello World %random%'
Pop $0
Pop 
$1
MessageBox MB_OK 
'Process exit code: $0$\n$\nStdOut: $1'
SectionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th September 2022, 18:13   #9
Mike-Sean
Junior Member
 
Join Date: Sep 2022
Posts: 7
Hi Pawel,

Did u get a chance to create the Plugin for the above data?
Mike-Sean is offline   Reply With Quote
Old 26th September 2022, 21:05   #10
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 558
Quote:
Originally Posted by Mike-Sean View Post
Did u get a chance to create the Plugin for the above data?
I am slowly trying to create something... But, it will take few more days...

You can check the follwoing demo. It should get info for Operating System and TPM

Ps: I am not promising anything more soon... However, I am planning to add CPU/RAM and maybe Storage info tomorrow....

Edit: Link removed. See below.

Last edited by Pawel; 28th September 2022 at 14:02.
Pawel is offline   Reply With Quote
Old 28th September 2022, 14:16   #11
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 558
SysInfo 1.0 Plugin for NSIS is now ready to test.

Plugin should run in Windows 7/8/10/11 with NSIS (unicode).
Current version of plugin allows you to get the following data:

OPERATING SYSTEM
OS Caption | Manufacturer | Version | Build Number | Language | Locale | Code Set |
Country Code | Edition ID | Display Version | Current Build Number | UBR | ReleaseID


PROCESSOR (CPU)
CPU Name | Description | Family | Manufacturer | Number of Cores | Number of Logical Processors |
Architecture | Clock Speed | External Clock Speed | L2 Cache Size | L3 Cache Size


MEMORY
Total Physical Memory | Free Physical Memory | Used Physical Memory
Total Virtual Memory | Free Virtual Memory | Used Virtual Memory
Total PageFile Memory | Free PageFile Memory | Used PageFile Memory
Total Installed Memory | Total Reserved Memory


STORAGE DEVICE
Disk Name | Disk Serial Number | Disk File System | Disk Drive Type | Disk Media Type
Disk Drive Total Size | Disk Drive Free Space | Disk Drive Used Space
Drive Media Type | Drive Model | Drive Description | Drive Manufacturer | Drive Serial Number
Drive Interface Type | Drive Media Type | Drive Total Cylinders | Drive Tracks/Cylinder
Drive Total Tracks | Drive Sectors/Track | Drive Total Sectors | Drive Bytes/Sector |
Drive Total Heads | Drive Size


TRUSTED PLATFORM MODULE
IsActivated_InitialValue | IsEnabled_InitialValue | IsOwned_InitialValue |
SpecVersion | ManufacturerVersion | ManufacturerVersionInfo | ManufacturerId | PhysicalPresenceVersionInfo


Please, take a look into attached demo script, where you can see how to use it.

-Pawel
Attached Files
File Type: zip SysInfo1.0.zip (821.0 KB, 51 views)

Last edited by Pawel; 28th September 2022 at 16:02.
Pawel is offline   Reply With Quote
Old 28th September 2022, 20:47   #12
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,541
Quote:
Originally Posted by Pawel View Post
PROCESSOR (CPU)
Which CPU does it get this information from? We now have asymmetrical CPUs (A.K.A big.LITTLE). Intel calls these cores P-Cores and E-Cores and they are effectively different CPUs inside a single CPU chip. On top of this Windows Server probably supports hot-swapping CPUs.

A few suggestions:

Support queries for specific CPUs. Just naming these is hard. One solution is processor groups. When there are more than 64 cores there will be multiple groups. Input like "1.5" would mean core #5 in group #1. This scheme is annoying for the caller and maybe even annoying to implement with WMI but is easy with raw Win32. The other would just be a simple number ("winmgmts:root\cimv2:Win32_Processor='cpu0'"). Or support both.

Something to help the OP here: GetFastestCPUMaximumCoreSpeed and GetSlowestCPUMaximumCoreSpeed. This should cover P-Cores vs E-Cores? For a game you probably only care about GetFastestCPUMaximumCoreSpeed.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th September 2022, 20:56   #13
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,541
Not wanting to mess with CPU specifics, I made a wiki page that dumps some information. (No TPM support since I don't have one)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th September 2022, 21:06   #14
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 558
Quote:
Originally Posted by Anders View Post
Support queries for specific CPUs.
There is a problem with devices that are more then 1 (CPU or Graphic Card, etc)
I still don't know what would be the best for script user (dll caller).

Maybe:
CPU Name 1 | CPU Name 2
CPU Speed 1 | SPU Speed 2

But, user would have to know there are more then 1 device and would have to split it by "|".
Graphic Card is a good example (it can be gpu buil-in CPU and external dedicated gpu). Maybe the answer is to chose active (default) and display info only for that one...
How do you think?
Pawel is offline   Reply With Quote
Old 28th September 2022, 21:56   #15
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,541
For graphic cards it probably makes sense to return information for the default/currently active. Perhaps a parameter that you set to "" for the default or a number/index for a specific GPU if the user wants to check all of them.

For CPUs the same somewhat applies although my suggestion for GetFastestCPUMaximumCoreSpeed should check all the CPUs and just return a usable number. I don't like the | pipe idea. Just using "" as input for some kind of default and an index or group/index pair for a specific CPU. What is the default? Who knows. Up until 2021 it did not matter much, most people just took the information from whatever CPU your thread is currently on but with the introduction of P/E cores you actually need to be specific in your internal code and should probably return the fastest CPU as the default.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th September 2022, 22:09   #16
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 558
If I understand you well... Let's assume we have 2 CPU's .
So, I should get clock speed for first CPU and second CPU. Compare them and return data for faster cpu... Than can be done relatively easy.

Btw, most computers have 1 CPU and 1 graphic card.
Pawel is offline   Reply With Quote
Old 28th September 2022, 23:43   #17
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,541
Just to clarify, when I say CPU (in software) I mean physical core or logical core, never physical package/socket. Most CPUs these days have multiple physical cores.

A physical CPU package (the hardware chip you see on the motherboard with your eyes) is usually just one except on big servers. They contain one or several physical cores. Each physical core is able execute one or several logical cores (hyper threading).

GetFastestCPUMaximumCoreSpeed should compare either every physical core or every logical core. The result should be the same AFAIK but testing logical cores may be easier.


(2 physical packages, 4 cores in each for a total of 8. 16 logical cores in total.)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 29th September 2022, 07:40   #18
Pawel
Moderator
 
Pawel's Avatar
 
Join Date: Aug 2004
Location: Poland
Posts: 558
Quote:
Originally Posted by Anders View Post
Just to clarify, when I say CPU (in software) I mean physical core or logical core, never physical package/socket. Most CPUs these days have multiple physical cores.
I fully agree. But, the plugin purpose is to show basic PC parameters to know software can be installed or not.

As you said, almost all PC has single CPU (with many cores/logical cores). But, in my opionion I don't need to get speed of single core. Just max clock is enough to know user can run installed software or not.

Example:
Let's assume that installed software require at least:
Specification:
- CPU 2 [GHz]
- RAM 8 [GB]
- VRAM 2 [GB]

NSIS script can get that data using the SysInfo plugin and make a comparison.
User:
- CPU 2.4 [GHz] -> OK
- RAM 16 [GB] -> OK
- VRAM 1 [GB] -> ! -> Can not install - not enough memory.


There is a small problem with multiple devices, best example is Video Adapter (Graphic Card). My laptop has 2 GPU:
- integrated with CPU (Intel 4600)
- dedicated GPU (GeForce GTX 850M)
What is the best way to choose better one? I decided to use the following alghoritm.

I get graphics card RAM ("AdapterRAM" in WMI Win32_VideoController class query) for each graphic card and gather data for GPU with more RAM. Simple and easy!

Of course, the problem is that in my laptop my GeForce is Offline (Intel is active). However, NVIDIA GPU is more powerfull and this is the choice (if user for example install a game that requires more GPU RAM).

I will try to implement this in SysInfo 1.1
Pawel is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump