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
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
342 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 102
When i run adoquery my application freezes 26 178
Path to Python 9 128
Embarcadero C++ builder XE10.1 Berlin TRegistry declaration 1 39
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 a problem I had getting the GPS LocationListener working.
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 …

860 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