Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enumerate hard disks, exclude partitions
#7
programming is not always simple. there are many factors and many lines that need to be parsed.
just because in our thoughts it's simple doesn't mean it will be in programming
to extract the information you want try this
also change diskpartinfo.txt to

list disk
sel disk 0
list part
list disk
sel disk 1
exit
 dont need the second list disk command
Code:
Copy      Help
_s.expandpath("$desktop$\diskpartinfo.txt")
str s cl=F"cmd.exe /C diskpart /s ''{_s}''"
RunConsole2 cl s
s.trim
int i t tt ttt
str ss disklist partitionlist1 partitionlist2
ARRAY(str) a=s
for(i a.len-1 -1 -1)
,if a[i].len = 0
,,a.remove(i)
for i 0 a.len
,a[i].trim
,ss=a[i]
,;out ss
,if(findrx(ss "Disk(?=\s\d*\s+Online)" 0 0) >=0)
,,if ttt=0
,,,disklist+ ss
,,,ttt+1
,,else
,,,disklist+"[]"
,,,disklist+ ss
,,,ttt+1
,if ss="Disk 0 is now the selected disk."
,,t=find(ss "Disk 0 is now the selected disk." 0 1)
,if ss!="Disk 1 is now the selected disk."    
,,if(findrx(ss "Partition(?=\s\d+)" t 0 0)>=0)
,,,if tt=0
,,,,partitionlist1+ ss
,,,,tt+1
,,,else
,,,,partitionlist1 + "[]"
,,,,partitionlist1 +ss
,,,,tt+1
,if ss="Disk 1 is now the selected disk."
,,t=find(ss "Disk 1 is now the selected disk." 0 1)
,,tt=0
,,if(findrx(ss "Partition(?=\s\d+)" t 0 0)>=0)
,,,if tt=0
,,,,partitionlist2+ ss
,,,,tt+1
,,,else
,,,,partitionlist2 + "[]"
,,,,partitionlist2 +ss
,,,,tt+1            
;out disklist
int disknum= numlines(disklist)
out "You currently have %i hard drives" disknum
;out partitionlist1
int part1num= numlines(partitionlist1)
out "The first hard drive has %i partitions" part1num
int part2num= numlines(partitionlist2)
out "The second hard drive has %i partitions" part2num
;out partitionlist2


Messages In This Thread
Enumerate hard disks, exclude partitions - by win - 09-08-2018, 09:34 PM
RE: Enumerate hard disks, exclude partitions - by Kevin - 09-09-2018, 05:34 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)