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
330 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
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
big_daddy0690 earned 500 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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tidtcpserver connection lost handle 2 86
SUM 2 INTEGER ARRAYS INTO 1 10 100
Java Loop 6 61
Full Screen problem when auto scale IFRAME 2 81
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

778 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