Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
?
387 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

Industry Leaders: 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

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

597 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