Задайте вопросЗадайте вопрос
 

ВопросСкрипт собирающий информацию о железе (bat)

  • 27 марта 2008 г. 8:44RuVirus Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Добрый день!

    Вот хотелось бы автоматизировать сбор информации о железе пользователей.

    Грубо говоря, не могли бы вы подсказать источники где можно найти описания команд выводящих Процессор, оперативную память и т.д.

    Создается такой скрипт:

    echo Инвентаризация >> C:\Inventarizacia.txt
    echo %username% >> C:\Inventarizacia.txt
    echo %computername% >> C:\Inventarizacia.txt
    ***

    Так же полная комплектация по компу.
    Давно находил такой батник, но вот потерял...

Все ответы

  • 27 марта 2008 г. 9:4201MDM Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    systeminfo
    netsh diag show computer /v
    netsh diag show os /v

    Различные псевдонимы для wmic (можно просмотреть  введя  wmic  /?)
    Например:
    wmic  cpu get name

    Вы лучше напишите, что конкретно необходимо узнать. Список может быть очень большим, если  не  известно что надо. 
  • 27 марта 2008 г. 11:15Andrey Nepomnyaschih Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Наиболее полным источником наверное будут классы WMI, список классов которые доступны можно посмотреть здесь

  • 28 марта 2008 г. 11:12Andrey Kudrjashov Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    Есть программа SIW. Unlimited версия стоит $69. (Просьба не считать рекламой)

     

    Вот перечень опций, доступных из командной строки, дальше дело техники:

    http://www.gtopala.com/siw-command-line.html

     

     

     

  • 31 марта 2008 г. 12:22КГБ Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    systeminfo не устраивает?

     

     

  • 17 апреля 2008 г. 0:46A-s-i-a Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    Советую программу everest (http://www.lavalys.com/, в сети полно ломанных экземпляров) устанавливать на компы не нужно, достаточно при логоне запустить из шары в командной строке (в справке everest описаны все команды) и получить инвентаризацию в txt, xls, cvs, htm, итд файле.

     

    Ну или в конце концов в скриптцентре полно примеров (http://www.microsoft.com/rus/technet/scriptcenter)...

  • 29 июля 2008 г. 13:47Sergey345 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
  • 6 августа 2008 г. 7:40IMasberg Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    on error resume next
    compname="localhost"
    'сервер и база

    str0 = "Provider=SQLOLEDB.1;Data Source=server.domen.ru;Initial Catalog=Inventory"
    'пользователь и имя таблицы

    str1 = "Invent001"
    'пароль

    str2 = "1"
    Set objConn = CreateObject("ADODB.Connection")
    Set objCmd = CreateObject("ADODB.Command")
    Set objRS = CreateObject("ADODB.RecordSet")
    objConn.Open str0,str1,str2
    Set objCmd.ActiveConnection = objConn
    Set compinfo = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & compname & "\root\cimv2").ExecQuery("select * from Win32_ComputerSystem")
    Set diskinfo = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & compname & "\root\cimv2").ExecQuery("select * from Win32_DiskDrive")
    Set biosinfo = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & compname & "\root\cimv2").ExecQuery("select * from Win32_BIOS")
    Set ipinfo   = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & compname & "\root\cimv2").ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

    'первый непустой IP

    For each ip1   in ipinfo
     If Not IsNull(ip1.IPAddress) Then
          For i=LBound(ip1.IPAddress) to UBound(ip1.IPAddress)
              If ip1.IPAddress(i) <> "0.0.0.0" Then
                ipcomp=ip1.IPAddress(i)
         maccomp=ip1.MACAddress
              End If
            Next
     End If
    Next

     

    For each comp1 in compinfo
    'первый диск

    For each disk1 in diskinfo
    For each bios1 in biosinfo

    objCmd.CommandText = "INSERT INTO " & str1 & " ([username],[compname],[model],[memory],[comptime],[disk0], [serialn],[ip0],[mac0]) VALUES("_
       & "'" & comp1.UserName & "','"  & comp1.Name & "','" & comp1.Model & "','" & comp1.TotalPhysicalMemory & "','" & Date() & " " & Time() & "','" & disk1.Size & "','" & bios1.SerialNumber & "','" & ipcomp & "','" & maccomp & "');"
    objRS.Open objCmd

    Exit For
    Next
    Exit For
    Next
    Exit For
    Next

     

    Коряво, но работает из логинскрипта, пишет в базу SQL
  • 4 октября 2008 г. 8:04Andrew Mishechkin Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    Вот что накопал из своих старых разработок. Код, может быть, и не слишком красивый, но я его с тех пор так и не менял. А зачем, если работает ?

    Code Snippet

    /****************************************************************************
    NAME: hw.js
    AUTHOR: Adrew Mishechkin
    DATE  : 1.12.2005
    ***************************************************************************/

    //Common variables
    var ComputerName;           //Local computer name
    var report;

    var Args = WScript.Arguments;       //аргументы командной строки
    if(Args.Length == 1)
    {        
     if(Args(0) != "/?")
      var ComputerName = Args(0);
     else
     {
      WScript.Echo("Use [cscript/wscript] hw.js ComputerName");
      WScript.Quit();
     }
    }
    else                //Неправильные аргументы коммандной строки
    {            
     WScript.Echo("Use [cscript/wscript] hw.js ComputerName");
     WScript.Quit(); 
    }

    var fso = WScript.CreateObject("Scripting.FileSystemObject");     // File System Object Creation
    var report = fso.CreateTextFile(ComputerName + ".txt",true);    //report file

    report.WriteLine("Computer: " + ComputerName);
    report.WriteLine("====================================================");
    report.WriteBlankLines(1);

    //////////////////////////////////////////////
    //  Считывание параметров оборудования      //
    //////////////////////////////////////////////
    var objWMIService = GetObject("winmgmts://" + ComputerName + "/root/cimv2");
     
    //Считывание типа CPU
    var wmiCPU = new Enumerator(objWMIService.ExecQuery("Select Name from Win32_Processor"));
    report.WriteLine("CPU model name: " + wmiCPU.item().Name);
    report.WriteBlankLines(1);

    //Cчитывание параметров материнской платы
    if(ReadCaption("Mainboard: ","Win32_BaseBoard", "NoString") != "undefined")
    {
     var wmiMB = new Enumerator(objWMIService.ExecQuery("Select * from Win32_BaseBoard"));
     report.WriteLine("Mainboard model: " + wmiMB.item().Product);
     report.WriteLine("Mainboard manufacturer: " + wmiMB.item().Manufacturer);
     report.WriteLine("Mainboard serial number: " + wmiMB.item().SerialNumber);
     report.WriteBlankLines(1);
    }

    //Считывание параметров BIOS
    if(ReadCaption("BIOS: ","Win32_BIOS", "NoString") != "undefined")
    {
     var wmiBIOS = new Enumerator(objWMIService.ExecQuery("Select * from Win32_BIOS"));
     report.WriteLine("BIOS name: " + wmiBIOS.item().Name);
     report.WriteLine("BIOS maufacturer: " + wmiBIOS.item().Manufacturer);
     report.WriteLine("BIOS version: " + wmiBIOS.item().Version);
     report.WriteLine("BIOS bulid number: " + wmiBIOS.item().BuildNumber);
     report.WriteLine("BIOS release date: " + wmiBIOS.item().ReleaseDate);
     report.WriteBlankLines(1);
    }

    //Считывание параметров ОЗУ
    var wmiComputerSystem = new Enumerator(objWMIService.ExecQuery("Select TotalPhysicalMemory from Win32_ComputerSystem"));
    report.WriteLine("Total physical memory: " + Math.round(wmiComputerSystem.item().TotalPhysicalMemory/1048576) + " Mb");
    report.WriteBlankLines(1);
     
    //Считывание параметров IDE контролеров
    ReadCaption("IDE controller: ", "Win32_IDEController");
     
    //Считывание параметров SCSI контроллеров
    ReadCaption("SCSI controller: ", "Win32_SCSIController");
     
    //Считывание параметров жестких дисков
    var NoDrives = false
    try
    {
     var wmiHDD = new Enumerator(objWMIService.ExecQuery("Select * from Win32_DiskDrive"));
    }
    catch(e)
    {
     if(e != 0)
      NoDrives = true
    }
    if(!NoDrives)

     var i = 0;
     for(;!wmiHDD.atEnd();wmiHDD.moveNext())
     {
       report.WriteLine("Drive"+(i+1)+":");
       report.WriteLine("HDD device ID: " + wmiHDD.item().DeviceID);
       report.WriteLine("HDD model: " + wmiHDD.item().Model);
       report.WriteLine("HDD interface: " + wmiHDD.item().IntrefaceType);
       if(wmiHDD.item().InterfaceType == "SCSI")
       { 
        report.WriteLine("HDD SCSI bus: " + wmiHDD.item().SCSIBus);
        report.WriteLine("HDD SCSI LUN: " + wmiHDD.item().SCSILogicalUnit);
        report.WriteLine("HDD SCSI port: " + wmiHDD.item().SCSIPort);
        report.WriteLine("HDD SCSI target ID: " + wmiHDD.item().SCSITargetId);
       }
       report.WriteLine("HDD size: " + Math.round(wmiHDD.item().Size/1073741824) + " Gb");
       report.WriteLine("Amount of partitions on drive: " + wmiHDD.item().Partitions);
       report.WriteLine("HDD signature: " + wmiHDD.item().Signature);
       report.WriteLine("Total cylinders: " + wmiHDD.item().TotalCylinders);
       report.WriteLine("Total heads: " + wmiHDD.item().TotalHeads);
       report.WriteLine("Total sectors: " + wmiHDD.item().TotalSectors);
       report.WriteLine("Total tracks: " + wmiHDD.item().TotalTracks);
       report.WriteLine("Bytes per sector: " + wmiHDD.item().BytesPerSector);
       report.WriteLine("Sectrors per track: " + wmiHDD.item().SectorsPerTrack);
       report.WriteLine("Tracks per cylinder: " + wmiHDD.item().TracksPerCylinder);
       report.WriteBlankLines(1);
       i++;
     }
    }
    else
    {
     report.WriteLine("No drives or Win32_DiskDrive WMI class error.");
     report.WriteBlankLines(1);
    }

    //Считывание параметров FDD
    ReadCaption("FDD: ", "Win32_FloppyDrive");
     
    //Считывание параметров CDROM
    ReadCaption("CDROM: ", "Win32_CDROMDrive");

    //Считываение параметров видеокарты
    if(ReadCaption("Video controller model: ","Win32_VideoController", "NoString") != "undefined")
    {
     var wmiVGA = new Enumerator(objWMIService.ExecQuery("Select * from Win32_VideoController"));
     report.WriteLine("Video processor: " + wmiVGA.item().VideoProcessor);
     report.WriteLine("Video RAM size: " + wmiVGA.item().AdapterRAM/1048576 + " Mb");
     report.WriteLine("Video driver: " + wmiVGA.item().InstalledDisplayDrivers);
     report.WriteLine("Video driver version: " + wmiVGA.item().DriverVersion);
     report.WriteLine("Video mode: " + wmiVGA.item().VideoModeDescription);
     report.WriteBlankLines(1);
    }

    //Считываение параметров монитора 
    ReadCaption("Monitor: ","Win32_DesktopMonitor");
     
    //Считывание параметров сетевых адаптеров
    var NoNIC = false
    try
    {
     var wmiNIC = new Enumerator(objWMIService.ExecQuery("Select * from Win32_NetworkAdapter"));
    }
    catch(e)
    {
     if(e!=0)
      NoNIC = true;
    }
    if(!NoNIC) 
    {
     for(;!wmiNIC.atEnd();wmiNIC.moveNext())
     {
      report.WriteLine("Network adapter model name: " + wmiNIC.item().Name);
      report.WriteLine("Network adapter manufacturer: " + wmiNIC.item().Manufacturer);
      if(wmiNIC.item().ConfigManagerErrorCode == 0)
       report.WriteLine("Network adapter is working properly");
      else if(wmiNIC.item().ConfigManagerErrorCode == 22)
       report.WriteLine("Network adapter is disabled");
      else if(wmiNIC.item().ConfigManagerErrorCode == 11)
       report.WriteLine("Network adapter failed");
      else if(wmiNIC.item().ConfigManagerErrorCode == 1)
       report.WriteLine("Network adapter is not configured correctly");
      else if(wmiNIC.item().ConfigManagerErrorCode == 2)
       report.WriteLine("Windows cannot load the driver for this network adapter");
      else if(wmiNIC.item().ConfigManagerErrorCode == 6)
       report.WriteLine("The boot configuration for this network adapter conflicts with other devices.");
      else if(wmiNIC.item().ConfigManagerErrorCode == 24)
       report.WriteLine("This network adapter is not present, is not working properly, or does not have all its drivers installed.");
      else if(wmiNIC.item().ConfigManagerErrorCode == 28)
       report.WriteLine("The drivers for this device are not installed.");
      else if(wmiNIC.item().ConfigManagerErrorCode == 30)
       report.WriteLine("This network adapter is using an IRQ that another device is using.");
      else if(wmiNIC.item().ConfigManagerErrorCode == null)
       report.WriteLine("Network adapter status undefined");
      else
       report.WriteLine("Network adapter status code: " + wmiNIC.item().ConfigManagerErrorCode);
      report.WriteLine("Network adapter type: " + wmiNIC.item().AdapterType);
      report.WriteLine("Network adapter device ID: " + wmiNIC.item().DeviceID);
      report.WriteLine("Network connection name: " + wmiNIC.item().NetConnectionID);
      report.WriteLine("MAC address: " + wmiNIC.item().MACAddress);  
      if((wmiNIC.item().NetConnectionStatus == 1)||(wmiNIC.item().NetConnectionStatus == 2))
       report.WriteLine("Network connection status: connected.");
      else if((wmiNIC.item().NetConnectionStatus == 0)||(wmiNIC.item().NetConnectionStatus == 3))
       report.WriteLine("Network connection status: diconnected.");
      else if(wmiNIC.item().NetConnectionStatus == null)
       report.WriteLine("Network connection status: undefined.");
      else
       report.WriteLine("Network connection status: " + wmiNIC.item().NetConnectionStatus);
      report.WriteBlankLines(1);
     }
    }
    else
    {
     report.WriteLine("No network adapters or Win32_NetworkAdapter WMI class error");
     report.WriteBlankLines(1);
    }

    //Считывание параметров звуковой карты
    ReadCaption("Sound device: ", "Win32_SoundDevice");

    //Считывание параметров клавиатуры
    ReadCaption("Keyboard: ", "Win32_Keyboard");

    //Считываение параметров мыши
    if(ReadCaption("Mouse: ","Win32_PointingDevice") != "undefined")

     var wmiMouse = new Enumerator(objWMIService.ExecQuery("Select * from Win32_PointingDevice"));
     if(wmiMouse.item().DeviceInterface == 4)
      report.WriteLine("Mouse interface: PS/2");
     else if(wmiMouse.item().DeviceInterface == 3)
      report.WriteLine("Mouse interface: Serial");
     else if(wmiMouse.item().DeviceInterface == 162)
      report.WriteLine("Mouse interface: USB");
     else if(wmiMouse.item().DeviceInterface != null)
      report.WriteLine("Mouse interface: undefined");
     else
      report.WriteLine("Mouse interface code: " + objItem.DeviceInterface);
     report.WriteBlankLines(1);
    }

    //Считываение параметров принтера
    NoPrinters = false
    try
    {
     var wmiPrinter = new Enumerator(objWMIService.ExecQuery("Select * from Win32_Printer"));
    }
    catch(e)
    {
     if(e!=0)
      NoPrinters = true;
    }
    if(!NoPrinters)
    {
     i = 0;
     for(;!wmiPrinter.atEnd();wmiPrinter.moveNext())
     {
      report.WriteLine("Printer model: " + wmiPrinter.item().Name);
      report.WriteLine("Printer port: " + wmiPrinter.item().PortName);
      if(wmiPrinter.item().Network == true)
      {
       report.WriteLine("Printer server: " + wmiPrinter.item().ServerName);
        report.WriteLine("Printer share: " + wmiPrinter.item().ShareName);
      }
      report.WriteLine("Printer location: " + wmiPrinter.item().Location);
      report.WriteLine("Printer comment: " + wmiPrinter.item().Comment);
      report.WriteBlankLines(1);
      i++;
     }
     if(i==0)
     {
      report.WriteLine("No printers");
      report.WriteBlankLines(1);
     }
    }
    else
    {
     report.WriteLine("No printers or Win32_Printer WMI class error"); 
     report.WriteBlankLines(1);
    }

    //Считываение параметров модема
    NoModems = false
    try
    {
     var wmiModem = new Enumerator(objWMIService.ExecQuery("Select * from Win32_POTSModem"));
    }
    catch(e)
    {
     if(e!=0)
      NoModems = true;
    }
    if(!NoModems)
    {
     i = 0;
     for(;!wmiModem.atEnd();wmiModem.moveNext())
     {
      report.WriteLine("Modem model: " + wmiModem.item().Caption);
      report.WriteLine("Modem port: " + wmiModem.item().AttachedTo);
      report.WriteLine("Modem type: " + wmiModem.item().DeviceType);
      report.WriteLine("Modem port baud rate: " + wmiModem.item().MaxBaudRateToSerialPort);
      report.WriteBlankLines(1);
      i++;
     }
     if(i==0)
     {
      report.WriteLine("No modems");
      report.WriteBlankLines(1);
     }
    }  
    else
    {
     report.WriteLine("No modems or Win32_Modem WMI class error");
     report.WriteBlankLines(1);
    }
    report.Close();

    ////////////////////////////////////////////////////////
    //   Открываем файл отчета в блокноте                 //
    ////////////////////////////////////////////////////////
    var WshShell = WScript.CreateObject("WScript.Shell");            // WSH Shell Object
    WshShell.Exec("notepad " + ComputerName+".txt");
    WScript.Quit(0);

    /**********************************************************/
    /*     Функция определения главного свойства WMI объекта  */
    /**********************************************************/
    function ReadCaption(deviceName,deviceClass,NoString)
    {
     DeviceUndefined = false;
     try
     {
      var wmiDevice = new Enumerator(objWMIService.ExecQuery("Select Caption from " + deviceClass));
      var deviceCaption = wmiDevice.item().Caption
     }
     catch(e)
     {
      if(e!=0)
       DeviceUndefined = true;
     }
     if(!DeviceUndefined)
     {
      report.WriteLine(deviceName + deviceCaption);
      if(NoString == null)
       report.WriteBlankLines(1);
      return 0;
     }
     else
      return "undefined";
    }