- How to get computer make and model
- Find computer make and model from CMD
- Find laptop model
- Сисадмину: наиболее полезные WMI запросы
- System Information. Computer Name Свойство
- Определение
- Значение свойства
- Примеры
- Комментарии
- GetComputerNameA function (winbase.h)
- Syntax
- Parameters
- Return value
- Remarks
- Examples
- How can I get the active user name in a SYSTEM process using C++?
- 5 Answers 5
How to get computer make and model
This post explains how to get computer make and model (like manufacturer name, model number) and other hardware details from Windows command prompt. The below commands should work on every edition of Windows(Windows 7, Windows 8, Windows 10) having WMIC.
Find computer make and model from CMD
Just run the command given below to get computer model.
There’s another command which can be used to get the computer system model information. We can also get architecture(32bit/64bit) using this command.
Based on the information you require, you can use any of the above commands. These commands return the following information on my computer.
On another laptop of mine, I see the below output for the above two commands.
Find laptop model
You can use the below command to get the model of the laptop.
This command would be useful to remotely fetch the model information from a bunch of computers in the network. We need to invoke this command on each of the computers and obtain the information.
Thanks very much for this. Don’t know why this isn’t on every manufacturer’s support site
Hi
i got clear idea, with this information
great information is it possible to have also the year of manufacture?
Neither command works for me on a W2K8 machine.
Go to windows icon > run > msinfo32
Hi. I tried both of these command prompts and I got nothing. The vendor showed up as “System Manufacturer” and version as “System Version”. Similarly with model I got “System Product Name”. What can I do to get the actual names?
Thanks a lot. These commands worked like a charm!
If you add /format:list, then you get =
missed some lines:
[parameter]=[value]
and if you also add | findstr/c:=, no empty lines will be shown.
missed some info:
parameter=value
Great stuff man. “wmic computersystem get model” is absolutely perfectly what I needed.
“and if you also add | findstr/c:=, no empty lines will be shown.”.
IT IS FANTASTIC!
Thanks, I had forgotten all my command knowledge and how useful they can be.
I will start re-learning them now.
cmd
wmic bios get serialnumber
it says..
wmic is not recognizable
pls help :'(
it want to install my wifi drivers for that i need it
Alternative is to run msinfo32 from Run window and check the model in ‘System summary’.
How can you find the Make and Model for remote device on the network?
Try: wmic /node:machinename computersystem get model
Thanks a lot, you’ve saved the day
The first of “Find laptop model” example was wrong for Lenovo, it should be:
C:\>wmic csproduct get version
Version
ThinkPad T430
Thank you very much help me alot
on my 5yr old hp pavallion, i get the return : ERROR:
Description = Not found.
any ideas ?
Hello,
I tried all the methods the version of the computer is right and i am getting but my model is no showing it says “system product name” when i search for model and when ever I search for the system manufacturer it says “system manufacturer”.Then what would I do please help me
Сисадмину: наиболее полезные WMI запросы
Очень часто для написания скриптов или фильтров требуется использовать WMI запросы. Я приведу те, которые встречаются чаще всего. В Windows есть встроенная утилита WMIC, которой можно выполнять запросы. Существует также язык WQL Query, который позволяет делать аналогичные запросы в различных системах, таких как SCCM.
Общий систаксис команды таков: wmic /namespace:\\root\ path get
В комманде вы указываете или путь к зарегистрированному классу, или его алиас. Аласы есть не для всех классов. Список достпных алиасов можно получить по команде: wmic /?. Остальные пути (path) можно узнать, скачав и запустив утилиту WMI Explorer:
Вы можете написать как полный путь wmic path Win32_computersystem get model, так и используя alias wmic computersystem get model, эти записи равноценны.
На языке WQL запрос будет выглядеть так:
SELECT * FROM Win32_ComputerSystem WHERE Name=’pc_name’
При написании скриптов на Powershell следует использовать команделт Get-WmiObject:
$computer = $env:COMPUTERNAME $namespace = «ROOT\cimv2» $classname = «Win32_ComputerSystem» Write-Output «=====================================» Write-Output «COMPUTER : $computer » Write-Output «CLASS : $classname » Write-Output «=====================================» Get-WmiObject -Class $classname -ComputerName $computer -Namespace $namespace | Select-Object * -ExcludeProperty PSComputerName, Scope, Path, Options, ClassPath, Properties, SystemProperties, Qualifiers, Site, Container | Format-List -Property [a-z]*
Вы можете писать и более сложные запросы, используя условие Where:
WMIC Path Win32_NetworkAdapter Where ( Manufacturer = «Realtek» And PhysicalAdapter = TRUE ) Get .
Вы можете вывести не одно, а несколько значений свойств сразу. Тогда они будут выводиться в виде таблицы со столбцами:
System Information. Computer Name Свойство
Определение
Возвращает имя NetBIOS локального компьютера. Gets the NetBIOS computer name of the local computer.
Значение свойства
Имя этого компьютера. The name of this computer.
Примеры
В следующем примере кода перечисляются все свойства SystemInformation класса в ListBox и отображается текущее значение свойства в, TextBox когда выбран элемент списка. The following code example lists all properties of the SystemInformation class in a ListBox and displays the current value of the property in a TextBox when a list item selected.
Комментарии
ComputerNameСвойство получает NetBIOS-имя локального компьютера. The ComputerName property retrieves the NetBIOS name of the local computer. Это достигается при вызове встроенной функции системной информации GetComputerName. This is accomplished with a call into the native System Information function GetComputerName. Это имя устанавливается при запуске системы, когда система считывает его из реестра. This name is established at system startup, when the system reads it from the registry. Если локальный компьютер является узлом кластера, ComputerName возвращает имя виртуального сервера кластера. If the local computer is a node in a cluster, ComputerName returns the name of the cluster virtual server.
С помощью метода можно ComputerName определить имя компьютера, который отображается для других пользователей в сети. You can use the ComputerName method to determine the name of the computer that is displayed to other users on a network.
GetComputerNameA function (winbase.h)
Retrieves the NetBIOS name of the local computer. This name is established at system startup, when the system reads it from the registry.
GetComputerName retrieves only the NetBIOS name of the local computer. To retrieve the DNS host name, DNS domain name, or the fully qualified DNS name, call the GetComputerNameEx function. Additional information is provided by the IADsADSystemInfo interface.
The behavior of this function can be affected if the local computer is a node in a cluster. For more information, see ResUtilGetEnvironmentWithNetName and UseNetworkName.
Syntax
Parameters
A pointer to a buffer that receives the computer name or the cluster virtual server name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1 characters.
On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs copied to the destination buffer, not including the terminating null character.
If the buffer is too small, the function fails and GetLastError returns ERROR_BUFFER_OVERFLOW. The lpnSize parameter specifies the size of the buffer required, including the terminating null character.
Return value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The GetComputerName function retrieves the NetBIOS name established at system startup. Name changes made by the SetComputerName or SetComputerNameEx functions do not take effect until the user restarts the computer.
If the caller is running under a client session, this function returns the server name. To retrieve the client name, use the WTSQuerySessionInformation function.
Examples
The winbase.h header defines GetComputerName as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
How can I get the active user name in a SYSTEM process using C++?
I have used GetUserName() METHOD , but the username it returned is ‘SYSTEM’ in a SYSTEM process.How can I get the active username in a SYSTEM process? THIS IS MY CODE:
5 Answers 5
You need to enumerate through all the running processes using EnumProcesses
Then see this answer to get the username from the process:
If you want to know who is logged onto the physical console, you can call WTSGetActiveConsoleSessionId to get the terminal services (aka «fast user switching» aka «remote desktop») session ID that is currently active.
You can then call WTSQuerySessionInformation with WTSUserName to get the username.
(If the user you’re interested in might be logged on via Remote Desktop, this approach will not work.)
The approach below will work for both physical console and virtual (remote desktop) console sessions.
Enumerating all processes is a way to do it, regardless of whether user is on the physical console or logged in via remote session, but it has certain issues:
1) You can’t enumerate both x86 and x64 processes in the same service process using documented Windows APIs. An x86 service can only enumerate x86 processes and an x64 service can only enumerate x64 processes. A way to circumvent that is to have an x86 service launch an x64 helper process (and vice versa) to do the rest of the enumeration task.
2) The only process that is always present for a logged on user across different Windows versions (e.g. Vista to Windows 10) is explorer.exe however that process is x64 on x64 OS platforms and x32 on x32 OS platforms and its presence does not mean that the user is actively logged in.
A better way is to enumerate sessions, find the active interactive session or sessions that is also connected and then get the user name of that session.
The code below does much more than that, including impersonation of that user and running a process as that user all from a windows service, but if you are just interested in the user name please look for the second instance the WTSQuerySessionInformation() function is called.