|
Answer» is there a way to test if a drive is available-ready or not using cmd-batch codes..??
im trying this: dir A:\ && start calc.exe and it outputs this: "The device is not ready." then nothing happens...
im TRY the same thing again but for a USB drive F:\ dir F:\ && start calc.exe the drive is there but no files are on it so it fials to DIR any files and then start calc.
so i want to be able to check to see if a drive is ready or not without having to check to see if it has files on it or not can this be done another way..??
like sumhow ping the drive to see if its active and if its active execute some code...As long as you GET the message "The device is not ready.", why don't you parse your OUTPUT and determine indirectly WHETHER the drive is ready or not.
On the other hand you can query the system directly:
Code: [Select]strComputer = "."
Set WshShell = CreateObject("Wscript.Shell") Set dct = CreateObject("Scripting.Dictionary") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk",,48) For Each objItem in colItems dct.Add objItem.Caption, "" Next
If dct.Exists("F:") Then WshShell.Run "calc.exe",,True
Save the script with a vbs extension and run from the command prompt as CSCRIPT scriptname.vbs
|