|
Answer» Hi !
Is there a way to get HDD ID using a BATCH file?
Thanks
Osmannot SURE if its device id you want. Code: [Select]Option Explicit Dim colItems,objWMIService,objItem Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive") For Each objItem in colItems Wscript.Echo "Device ID: " & objItem.DeviceID Next save as myscript.vbs and run from command prompt: cscript /nologo myscript.vbsDear ghostdog74,
I want to get HDD Serial number. My aim is to prevent my program to run on another PC by controlling HDD Serial number in a batch file.
Thank you for your help.wmic diskdrive get SERIALNUMBERFor me personally there is no value in the serialnumber of diskdrive. For me 'diskdrive get pnpdeviceid' seems to get some ID value.
Anyway, if you don't know how, this is how to use it in a batch file:
Quote @echo off set HDDID= for /f "usebackq skip=1 delims=" %%I in (`wmic diskdrive get PNPDeviceID`) do ( set HDDID=%%I goto out ) :out echo %HDDID% pause >nul I've found a way to control another unique number at last.
Thank you all for your help.
Osman well, then you should say "serial number" and not "ID". Code: [Select]Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") For Each drives In objFSO.Drives If drives.DriveLetter = "C" Then WScript.Echo "Serial number is ", drives.SerialNumber END If Next output: Code: [Select]Serial number is 202343032
|