2017-08-15 769 views

回答

0

我试图做同样的事情,发现可以通过WMI启动测试。查看ROOT\WMI名称空间下的WMI类MSStorageDriver_FailurePredictFunction。该类有几种不同的方法可以使用。其中之一是ExecuteSelfTest方法。 看看这个例子中,我与WMI代码造物主(WMICodeCreator

  try 
      { 
       ManagementObject classInstance = 
        new ManagementObject("root\\WMI", 
        "MSStorageDriver_FailurePredictFunction.InstanceName='SCSI\Disk&Ven_Hitachi&Prod_HDS721010CLA632\4&7d4adf0&0&010000_0'", 
        null); 

       // Obtain in-parameters for the method 
       ManagementBaseObject inParams = 
        classInstance.GetMethodParameters("ExecuteSelfTest"); 

       // Add the input parameters. 
       inParams["Subcommand"] = 1; 

       // Execute the method and obtain the return values. 
       ManagementBaseObject outParams = 
        classInstance.InvokeMethod("ExecuteSelfTest", inParams, null); 

       // List outParams 
       Console.WriteLine("Out parameters:"); 
       Console.WriteLine("ReturnCode: " + outParams["ReturnCode"]); 
      } 
      catch(ManagementException err) 
      { 
       MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message); 
      } 

您必须更改实例名在上面的代码到你的diskname创建。我还发现,"Subcommand"参数是决定你实际开始测试的因素。 如果值为1,则开始Short Self-test。 如果值为2,则开始Extended Self-test

正如你可以接收这三个值['0', '1', '2']的一个输出参数 而0代表'Successful Completion'1代表'Captive Mode Required'2代表'Unsuccessful Completion'。源(FailurePredictFunction

+0

感谢LuXxn,它是如此之大!。我已经通过这种方式来执行SMART Self-Test。 –

+0

我只能设法执行短自我测试和扩展自我测试。我无法通过其他测试来完成。你如何“跟踪”你的测试?你读过任何日志或东西,看看它是否成功? – Luca

0

感谢LuXxn,

我已经为你的向导成功,但我只许成功执行短Selft测试和扩展Selft测试。即使我的硬盘也支持立即以离线模式(值= 03h)测试SMART Conveyance自检程序。但它总是返回代码是1'Captive Mode Required'。你知道如何执行这个测试吗?

我跟着ATA/ATAPI注释设置ACS-3规范[表127,http://www.t13.org/Documents/UploadedDocuments/docs2013/d2161r5-ATAATAPI_Command_Set_-_3.pdf]确切地知道输入参数EXCUTE SMART Selft测试

inParams [ “子命令”] =值?;

/* ********************************************************************* 
     * Table 127 — SMART EXECUTE OFF-LINE IMMEDIATE Subcommands/Draft ATA/ATAPI Comment Set ACS-3 
     * http://www.t13.org/Documents/UploadedDocuments/docs2013/d2161r5-ATAATAPI_Command_Set_-_3.pdf 
     * Value Description of subcommand to be processed 
     * 00h  Execute SMART off-line routine immediately in off-line mode 
     * 01h  Execute SMART Short self-test routine immediately in off-line mode 
     * 02h  Execute SMART Extended self-test routine immediately in off-line mode 
     * 03h  Execute SMART Conveyance self-test routine immediately in off-line mode 
     * 04h  Execute SMART Selective self-test routine immediately in off-line mode 
     * 05h-3Fh Reserved 
     * 40h-7Eh Vendor specific 
     * 7Fh  Abort off-line mode self-test routine 
     * 80h  Reserved 
     * 81h  Execute SMART Short self-test routine immediately in captive mode 
     * 82h  Execute SMART Extended self-test routine immediately in captive mode 
     * 83h  Execute SMART Conveyance self-test routine immediately in captive mode 
     * 84h  Execute SMART Selective self-test routine immediately in captive mode 
     * 85h-8Fh Reserved 
     * 90h-FFh Vendor specific 
     * ********************************************************************/ 

要知道我的硬盘可以支持在离线模式下执行SMART运送自检,我送SMART命令来获得OfflineCollectCapability的值,然后返回值是0x73和遵循ATA/ATAPI注释设置ACS-3规格[表133 http://www.t13.org/Documents/UploadedDocuments/docs2013/d2161r5-ATAATAPI_Command_Set_-_3.pdf]

/********************************************************************** 
    * Table 133 — Offline Data Collection Capabilities 
    * Bit  Description 
    * 7  Reserved 
    * 6  SELECTIVE SELF-TEST IMPLEMENTED bit – If this bit is cleared to zero, the device does not implement the 
    *   Selective self-test routine. If this bit is set to one, the device implements the Selective self-test routine. 
    * 5  CONVEYANCE SELF-TEST IMPLEMENTED bit – If this bit is cleared to zero, the device does not implement the 
    *   Conveyance self-test routines. If this bit is set to one, the device implements the Conveyance self-test 
    *   routines. 
    * 4  SELF-TEST IMPLEMENTED bit – If this bit is cleared to zero, the device does not implement the Short and 
    *   Extended self-test routines. If this bit is set to one, the device implements the Short and Extended 
    *   self-test routines. 
    * 3  OFF-LINE READ SCANNING IMPLEMENTED bit – If this bit is cleared to zero, the device does not support 
    *   off-line read scanning. If this bit is set to one, the device supports off-line read scanning. 
    * 2  ABORT/RESTART OFF-LINE BY HOST bit – If this bit is set to one, then the device shall abort all off-line data 
    *   collection activity initiated by a SMART EXECUTE OFF-LINE IMMEDIATE command upon receipt of a 
    *   new command within 2 seconds of receiving the new command. If this bit is cleared to zero, the device 
    *   shall suspend off-line data collection activity after an interrupting command and resume off-line data 
    *   collection activity after some vendor-specified event. 
    * 1  Vendor specific. 
    * 0  EXECUTE OFF-LINE IMMEDIATE IMPLEMENTED bit – If this bit is set to one, then the SMART EXECUTE 
    *   OFF-LINE IMMEDIATE command is implemented by this device. If this bit is cleared to zero, then the 
    *   SMART EXECUTE OFF-LINE IMMEDIATE command is not implemented by this device. 
    * *******************************************************************/ 

感谢您的帮助,