?
Solved

How can I input the data returned by this code, into an array (via variables) and pass that along to the user (with the corresponding disk description) to allow them to select the applicable disk?

Posted on 2012-04-12
4
Medium Priority
?
373 Views
Last Modified: 2012-04-14
I composed this .vbs that will obtain the disk id and description. However, how can I input the data returned by this code, into an array and pass that along to the user (with the corresponding disk description) to allow them to select the applicable disk, using AutoIT?

.vbs to obtain drive id and caption:

ComputerName = "."
Set wmiServices  = GetObject ( _
    "winmgmts:{impersonationLevel=Impersonate}!//" _
    & ComputerName)
' Get physical disk drive
Set wmiDiskDrives =  wmiServices.ExecQuery ( _
    "SELECT Caption, DeviceID FROM Win32_DiskDrive")

For Each wmiDiskDrive In wmiDiskDrives
        WScript.Echo "Disk drive Caption: " _
        & wmiDiskDrive.Caption _
        & VbNewLine & "DeviceID: " _
        & (Replace(wmiDiskDrive.DeviceID,"\\.\PHYSICALDRIVE",""))

Next


Note: Above code written in .vbs
Note: Working in Auto IT.




AutoIT Code (thus far):

    $ID = ""
    $Cap = ""

@ComputerName = "."
Set $wmiServices  = GetObject ( _
    "winmgmts:{impersonationLevel=Impersonate}!//" _
    & @ComputerName)
' Get physical disk drive
Set $wmiDiskDrives =  $wmiServices.ExecQuery ( _
    "SELECT Caption, DeviceID FROM Win32_DiskDrive")

    For $wmiDiskDrive In $wmiDiskDrives
        $ID = $ID & $wmiDiskDrive.DeviceID
        $Cap = $Cap & $wmiDiskDrive.Caption
    Next
0
Comment
Question by:2newbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
big_daddy0690 earned 2000 total points
ID: 37840044
I think this is what you are looking for.

#include <Array.au3>

$wmiServices = ObjGet("winmgmts:{impersonationLevel=Impersonate}!//" & @ComputerName)
; Get physical disk drive
$wmiDiskDrives = $wmiServices.ExecQuery("SELECT Caption, DeviceID FROM Win32_DiskDrive")

$iCount = $wmiDiskDrives.count
Dim $aInfo[$iCount][2]
$i = 0

For $wmiDiskDrive In $wmiDiskDrives
	$aInfo[$i][0] = $wmiDiskDrive.DeviceID
	$aInfo[$i][1] = $wmiDiskDrive.Caption
	$i += 1
Next

_ArrayDisplay($aInfo)

Open in new window

0
 

Author Comment

by:2newbie
ID: 37845470
Thanks,
That works great.

Follow Up Question, if possible?

How can I add these variables to a guictrl, I seem to be having an issue passing the data from the array to the guictrl?

I am using:


$wmiServices = ObjGet("winmgmts:{impersonationLevel=Impersonate}!//" & @ComputerName)
$wmiDiskDrives = $wmiServices.ExecQuery("SELECT Caption, DeviceID FROM Win32_DiskDrive")

$iCount = $wmiDiskDrives.count
Dim $aInfo[$iCount][2]
$i = 0

For $wmiDiskDrive In $wmiDiskDrives
      $aInfo[$i][0] = (StringReplace($wmiDiskDrive.DeviceID, "\\.\PHYSICALDRIVE", ""))
      $aInfo[$i][1] = $wmiDiskDrive.Caption
      $i += 1
Next

GUICtrlCreateGroup("Select the Disk to Duplicate:", 10, 105, 315, 70)
$Disk = GUICtrlCreateCombo("", 50, 135, 75)
GUICtrlSetData(-1, $aInfo[$i][0])
$DiskDesc = GUICtrlCreateLabel("", 60, 145, 75)
GUICtrlSetData(-1, $aInfo[$i][1])
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
0
 
LVL 8

Assisted Solution

by:big_daddy0690
big_daddy0690 earned 2000 total points
ID: 37845560
The variable $i is no longer appropriate to use after the previous for loop. I don't have access to the help file currently, but I believe there is an ArrayToString function that would turn the data into something usable for ...SetData. I'd normally write an example, but I'm on my iPad right now.
0
 

Author Comment

by:2newbie
ID: 37846491
perfect, got it. thanks again.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question