memchik

win32com.client

Sep 17th, 2021
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. import datetime
  3. import win32com.client
  4.  
  5. print (f"Дата и время: {datetime.datetime.now()}\n") #time
  6.  
  7.  
  8. # //////////////////////Не менять ничего тут/////////////////////////////
  9. strComputer = '.'
  10. objWMIService = win32com.client.Dispatch('WbemScripting.SWbemLocator')
  11. objSWbemServices = objWMIService.ConnectServer(strComputer,'root\\cimv2')
  12. # ///////////////////////////////////////////////////////////////////////
  13.  
  14. colItems = objSWbemServices.ExecQuery("SELECT * FROM Win32_ComputerSystem")
  15. for objItem in colItems:
  16.     if objItem.UserName != None:
  17.         print ('Имя устройства:', objItem.UserName.split('\\')[1])
  18.     if objItem.SystemType != None:
  19.         print ('Разрядность системы:', objItem.SystemType)
  20.  
  21.  
  22. colItems = objSWbemServices.ExecQuery("SELECT * FROM Win32_OperatingSystemAutochkSetting")
  23. for objItem in colItems:
  24.     if objItem.Setting != None:
  25.         print ("Версия ОС:", objItem.Setting.split('="')[1].split('|')[0])
  26. print ('Сборка ОС:', sys.getwindowsversion().build) #build windows
  27.  
  28. print('\nОперативная память:')
  29. colItems = objSWbemServices.ExecQuery('SELECT * FROM Win32_PhysicalMemory')
  30. for objItem in colItems:
  31.     print (f'Слот: {objItem.DeviceLocator}, Объем: {int(objItem.Capacity)/1024**3} GB, Скорость: {objItem.Speed}')
  32.  
  33. print('\nЖесткие диски:')
  34. colItems = objSWbemServices.ExecQuery('SELECT * FROM Win32_DiskDrive')
  35. for objItem in colItems:
  36.     if objItem.Model != None:
  37.         print ('Производитель и модель жесткого диска:' ,  objItem.Model)
  38.     if objItem.Size != None:
  39.         print ('Размер:', int(objItem.Size)/1024**3, 'GB')
  40.  
  41. print()
  42. colItems = objSWbemServices.ExecQuery('SELECT * FROM Win32_Processor')
  43. for objItem in colItems:
  44.     if objItem.Name != None:
  45.         print ('Название процессора:', objItem.Name)
  46.     if objItem.ProcessorId != None:
  47.         print ('ID процессора:', objItem.ProcessorId)
  48.  
  49. colItems = objSWbemServices.ExecQuery("SELECT * FROM Win32_Environment")
  50. for objItem in colItems:
  51.     if objItem.Name == 'NUMBER_OF_PROCESSORS':
  52.         print ("Количество ядер:", objItem.VariableValue)
  53.  
  54. colItems = objSWbemServices.ExecQuery("SELECT * FROM Win32_Process")
  55. print('Все действующие процессы:')
  56. for objItem in colItems:
  57.     if objItem.Name != None:
  58.         print (objItem.Name)
  59.  
RAW Paste Data