AutoHotkey Community

It is currently May 27th, 2012, 3:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: March 24th, 2010, 9:35 pm 
Offline

Joined: September 13th, 2009, 2:34 pm
Posts: 30
hi there!

I currently have a script which gathers system information and specific file versions, the output of the script gets emailed by the customer to me and I put it into an Excel.

This all works so far, just running into a small problem;

I'd like to get an overview of all the physical drives in the system and their corresponding driveletters. I currently do this by reading an XML generated by DXDiag.

I do this using this code:
Code:
COM_Init(), doc := COM_CreateObject("MSXML2.DOMDocument")
COM_Invoke(doc, "load", "c:\dxdiag.xml")   ; use "loadXML" to load xml data
graph := xmlget(doc, "//DisplayDevice/CardName/text()" )
graphmem := xmlget(doc, "//DisplayDevice/DisplayMemory/text()" )
graphdriv := xmlget(doc, "//DisplayDevice/DriverVersion/text()" )
windir := xmlget(doc, "//WindowsDir/text()" )
disks := xmlget(doc, "//LogicalDisks/LogicalDisk/Model/text()" )
volumes := xmlget(doc, "//LogicalDisks/LogicalDisk/DriveLetter/text()" )
StringReplace, disk, disks, `,, `n%A_Tab%, All
StringReplace, volumes, volumes, `,, `n%A_Tab%, All
COM_Release(doc), COM_Term()

The reason I'm replacing the commas for an {Enter} and Tabs is that it has to get pasted into the second column of the Excel. What this give me now is this:

Disks ST3500320AS ATA Device
ST3160023AS ATA Device C:
D:

I'd like it to be:

Disks ST3500320AS ATA Device C:
ST3160023AS ATA Device D:

I get this by doing:
Code:
FileAppend, Disks%A_Tab%%disk%%A_Tab%%volumes%, c:\test.txt


this text file is pasted into Excel afterwards on my end and gives the aforementioned result..

Anyone know how to do this?

I can of course FileAppend the 2 variables into 2 seperate text files and paste them manually into the correct column but the problem is that it's not always the same cell in that column. This is because the Dimms are also shown in the same way and some systems have 4, others 6 etc..

DXDiag creates an XML which can list the same drive multiple times when it has more than 1 partition so if anyone knows of a better way let me know..

Thanks ahead!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2010, 9:43 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
a) don't paste but use import tab delimited if you must, but
b) even better replace tab enter stuff with CSV which you an open right away in excel for further processing

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2010, 10:24 pm 
Offline

Joined: September 13th, 2009, 2:34 pm
Posts: 30
thanks for replying!

i don't see how using CSV would solve my issue? i would still be creating it using FileAppend? The problem is i can't get the physical drivename followed by it's drive letter {Enter} second physical drivename followed by it's driveletter?

correct me if i'm wrong but i don't see how using CSV would let me do this? it's still a text file created in the same way as the tab delimited file?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2010, 10:16 am 
Offline

Joined: September 13th, 2009, 2:34 pm
Posts: 30
Still wrestling with this one, I've now managed to get this information from WMI COM. This still doesn't solve my issue but dxdiag is no longer needed..

This is the syntax I use:
Code:
WMI_Query("\\.\root\cimv2", "Win32_LogicalDisk", "DeviceID")
Partitions := WMI_Query("\\.\root\cimv2", "Win32_LogicalDisk", "DeviceID")


I was wondering if I can query WMI for multiple values in 1 go? Maybe that could 'group' partitions, their hardware, size and driveletters?

Anyone know about this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2010, 10:43 am 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
Code:
StringReplace, disk, disks, `,, `n%A_Tab%, All
:?:

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2010, 3:03 pm 
Offline

Joined: September 13th, 2009, 2:34 pm
Posts: 30
hi nick,

at first i didn't know you can keep the same variable name so i changed disks to disk..

the reason i'm replacing the commas with `n%A_Tab% is so they were pasted into the correct cells in Excel.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 25 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group