Page 2 of 2 <12
Topic Options
#29394 - 2002-09-23 07:07 PM Re: WMIQuery DriveType 3 list
Anonymous
Unregistered


Waltz,

This worked:
code:
if exist ("s:\computing\scripts\wksta\" + @wksta + "_dr.txt")
goto "over"
else
$PC = @wksta
$outfile = "s:\computing\scripts\wksta\" + @wksta + "_dr.txt"
For Each $Disk In DiskInfo($PC)
if redirectoutput ("") = 0 ; send it to the screen
$Disk ?
endif
if redirectoutput ($outfile,1) = 0 ; send it to the file
$Disk ?
endif
Next
endif
; send it to the screen
if redirectoutput ("") = 0
? "stuff for the screen"
endif

If I didn't have the ENDIFs after the redirectoutput commands I'd get a FOR WITHOUT NEXT error.

I took out the RETURN. I have no idea why that was in there. It was in the code I pirated from Kholm so I left it there.

Thanks!

[ 23. September 2002, 19:14: Message edited by: Shane ]

Top
#29395 - 2002-09-23 07:13 PM Re: WMIQuery DriveType 3 list
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
Bingo...
My reworked one works also [Razz]
Cheers...
_________________________
We all live in a Yellow Subroutine...

Top
#29396 - 2002-09-23 07:24 PM Re: WMIQuery DriveType 3 list
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
have you looked at?:

"Select * from Win32_DiskPartition"

Access:
Availability:
BlockSize: 512
Bootable: -1
BootPartition: -1
Caption: Disk #0, Partition #0
ConfigManagerErrorCode:
ConfigManagerUserConfig:
CreationClassName: Win32_DiskPartition
Description: Installable File System
DeviceID: Disk #0, Partition #0
DiskIndex: 0
ErrorCleared:
ErrorDescription:
ErrorMethodology:
HiddenSectors:
Index: 0
InstallDate:
LastErrorCode:
Name: Disk #0, Partition #0
NumberOfBlocks: 39085137
PNPDeviceID:
PowerManagementCapabilities:
PowerManagementSupported:
PrimaryPartition: -1
Purpose:
RewritePartition:
Size: 20011590144
StartingOffset: 32256
Status:
StatusInfo:
SystemCreationClassName: Win32_ComputerSystem
SystemName: RADIMUS
Type: Installable File System

[ 23. September 2002, 19:26: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#29397 - 2002-09-23 07:35 PM Re: WMIQuery DriveType 3 list
Anonymous
Unregistered


Radimus:

Er, no, I haven't. Not that I would know what to do with it if I did, though. If you hadn't noticed I don't really know what I'm doing. I take scripts other people have done and modify them, if I can, to my own ends (Script Pirate?). If I can't modify it then I ask for help. But, thanks for the pointer; I'll file it away.

Anyhoo, I got your bit of code to do what I want (assuming it lists all local partitions, which I can't test yet):
code:
$name=	split(wmiquery("name","win32_logicalDisk",,"DriveType","3"),"|")
$fs= split(wmiquery("filesystem","win32_logicalDisk",,"DriveType","3"),"|")
$size= split(wmiquery("size","win32_logicalDisk",,"DriveType","3"),"|")
$fsp= split(wmiquery("freespace","win32_logicalDisk",,"DriveType","3"),"|")

if open (1,"s:\computing\scripts\wksta\" + @wksta + "_testdr.txt",5) = 0
for $loop=0 to ubound($name)
? @wksta + chr(9) + $name[$loop] + chr(9) + $fs[$loop] + chr(9) + $size[$loop] + chr(9) + $fsp[$loop]
writeline(1, @wksta + chr(9) + $name[$loop] + chr(9) + $fs[$loop] + chr(9) + $size[$loop] + chr(9) + $fsp[$loop] + chr(13) + chr(10))
next
close(1)
endif

So, see, I learn a bit from the things folks here show me. The responses in this thread have been a great help.

Top
#29398 - 2002-09-23 07:51 PM Re: WMIQuery DriveType 3 list
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
you could also do...
code:
for $loop=0 to ubound($name)
$hd =$size[$loop] $hdGB =left($hd,len($hd)-9)
$hdf =$fsp[$loop] $hdGBf =left($hdf,len($hdf)-9)

? $name[$loop]" "$fs[$loop]" "$hdGB"GB "$hdGBf"GB"
next

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#29399 - 2002-09-24 01:51 AM Re: WMIQuery DriveType 3 list
Anonymous
Unregistered


I managed to test this:
code:
$name=	split(wmiquery("name","win32_logicalDisk",,"DriveType","3"),"|")
$fs= split(wmiquery("filesystem","win32_logicalDisk",,"DriveType","3"),"|")
$size= split(wmiquery("size","win32_logicalDisk",,"DriveType","3"),"|")
$fsp= split(wmiquery("freespace","win32_logicalDisk",,"DriveType","3"),"|")

if open (1,"s:\computing\scripts\wksta\" + @wksta + "_testdr.txt",5) = 0
for $loop=0 to ubound($name)
? @wksta + chr(9) + $name[$loop] + chr(9) + $fs[$loop] + chr(9) + $size[$loop] + chr(9) + $fsp[$loop]
writeline(1, @wksta + chr(9) + $name[$loop] + chr(9) + $fs[$loop] + chr(9) + $size[$loop] + chr(9) + $fsp[$loop] + chr(13) + chr(10))
next
close(1)
endif

...on a system with lots of drives and partitions and it does indeed list each partition on its own line, just like I had hoped it would. Thanks, Radimus!

Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.057 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org