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
310 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
perfect, got it. thanks again.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changeXy challenge 13 56
array11 challenge 16 50
listing all functions in JavaScript 19 98
Image decoding from Camera 3 42
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now