"manu-l" <manu-> wrote in message
news:48a61e8e$0$950$...
>
> "Pegasus (MVP)" <> a écrit dans le message de news:
> %23068uhy$...
>>
>> "manu-l" <manu-> wrote in message
>> news:48a5e2da$0$904$...
>>> Hi all,
>>> I ve got a small trouble with my script.
>>> Here the script:
>>>
>>> @echo off
>>> @SETLOCAL ENABLEEXTENSIONS
>>> @SETLOCAL ENABLEDELAYEDEXPANSION
>>> FOR /F "tokens=1-6 " %%i IN ('"WMIC PATH win32_diskquota WHERE
>>> (QuotaVolume='Win32_LogicalDisk.DeviceID="D:"')get
>>> DiskSpaceUsed,Limit,QuotaVolume,User,WarningLimit" ') do @SET
>>> DiskSpaceUsed=%%i & @SET Limit=%%j & @SET QuotaVolume=%%k & @SET
>>> User=%%l & @SET WarningLimit=%%m
>>> @SET volume=!QuotaVolume:~27,5!
>>> @SET users=!user:~14,50!
>>> @SET /A totalbyte=!limit:~0,-11!
>>> @SET /A totalused=!DiskSpaceUsed:~0,-11!
>>> @SET /A warning=!WarningLimit:~0,-11!
>>> @echo warn:%warn% - limit: %totalbyte% - used: %totalused% -
>>> hardrive: %volume% - who: %users% - alert: %warning%
>>>
>>> The script it working well but only the last line of the wmi request is
>>> processing. How can i do to process all lines without an output file?
>>> Regards,
>>>
>>> Manu.
>>
>> IMHO this is a pretty horrible script. It has numerous "@" characters
>> where none are required, it uses several "poison" characters in its "for"
>> loop (Line #04 below), it uses "&" connectors where a set of
>> opening/closing
>> brackets would result in much less confusion, it misses several of the
>> same
>> connecting "&" connectors and it uses a few variables that are never
>> declared,
>> e.g. %warn%. The script below ***might*** do what you want (after you
>> have removed the line numbers and fixed up the obvious errors) but if you
>> tell
>> us what you're trying to achieve then someone will probably propose a
>> much
>> more elegant and maintainable solution.
>> 01. @echo off
>> 02. SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
>> 03. set Count=0
>> 04. rem FOR /F "tokens=1-6 " %%i IN ('"WMIC PATH win32_diskquota WHERE
>> ^(QuotaVolume='Win32_LogicalDisk.DeviceID="e:"'^) get
>> DiskSpaceUsed,Limit,QuotaVolume,User,WarningLimit" ') do (
>> 05. WMIC PATH win32_diskquota WHERE
>> (QuotaVolume='Win32_LogicalDisk.DeviceID="e:"') get
>> DiskSpaceUsed,Limit,QuotaVolume,User,WarningLimit > d:\temp\test.txt
>> 06. for /F "tokens=1-6" %%i in ('type d:\temp\test.txt') do call :Sub %%i
>> %%j %%k %%l %%m %%n
>> 07. goto :eof
>> 08.
>> 09. :Sub
>> 10. set /a count = %count% + 1
>> 11. if %count%==1 goto :eof
>> 12. echo i=%1
>> 13. echo j=%2
>> 14. echo k=%3
>> 15. echo l=%4
>> 16. echo m=%5
>> 17. echo n=%6
>> 18. SET DiskSpaceUsed=%1
>> 19. SET Limit=%2
>> 20. SET QuotaVoume=%3
>> 21. SET User=%4
>> 22. SET WarningLimit=%5
>> 23. SET volume=%QuotaVolume:~27,5%
>> 24. SET users=%user:~14,50%
>> 25. SET /A totalbyte=%limit:~0,-11%
>> 26. SET /A totalused=%DiskSpaceUsed:~0,-11%
>> 27. SET /A warning=%WarningLimit:~0,-11%
>> 28. echo warn:%warn% - limit: %totalbyte% - used: %totalused% -
>> hardrive: %volume% - who: %users% - alert: %warning%
>>
>>
>
>
> Thank you for correcting my script, i never see subruntime in batch before
> 
> Apolgize the forgot, the script is to report informations about quota over
> partitions
> (user, percent used, limit...) in plain text format.
> Asap I prefere do all in the process than use logfile injection that s why
> i didnt look for this option before. If there are no other solution i ll
> parse the log file.
>
> Manu
>
Try this Visual Basic script. It is much faster than WMC and it gives
you a nicely formatted output. Remember to run it with cscript.exe!
01. 'This program will extract the parameters of all existing drives.
02. Dim DType(6)
03. DType(0) = "Unknown"
04. DType(1) = "Removable"
05. DType(2) = "Fixed"
06. DType(3) = "Network"
07. DType(4) = "CDROM"
08. DType(5) = "RAMDisk"
09.
10. Set oFSO = CreateObject("Scripting.FileSystemObject")
11. Set drives = oFSO.Drives
12.
13. LF = Chr(10)
14.
15. Line = "Drive Type State Label F/S Size
Free Serial"
16. WScript.Echo Line
17. WScript.Echo String(Len(Line)+2, "-")
18. For Each drive In drives
19. D = drive.DriveType
20. if D > UBound(DType) then D = 0
21. Line = drive.Path & " " & DType(D)
22.
23. If drive.IsReady Then
24. Line = Append(Line, "ready", 18, False)
25. If drive.DriveType = 3 Then
26. Line = Append(Line, Left(drive.ShareName, 13), 29, False)
27. Else
28. Line = Append(Line, Left(drive.VolumeName, 13), 29, False)
29. End If
30.
31. Line = Append(Line, drive.FileSystem, 44, False)
32. Line = Append(Line, Int(drive.TotalSize/1000000), 51, True)
33. Line = Append(Line, Int(drive.FreeSpace/1000000), 59, True)
34. ' Line = Line & "Available=" & Int(drive.AvailableSpace/1000000)
35. Line = Append(Line, Hex(drive.SerialNumber), 67, False)
36. Else
37. Line = Append(Line, "not ready", 18, False)
38. End If
39. WScript.Echo Line
40. Next
41.
42. Function Append(L, S, n, numerical)
43. if n < Len(L) + 2 then n = 2 Else n = n - Len(L)
44. If numerical Then
45. Append = L & Left(Space(60), n + 6 - Len(S)) & S
46. Else
47. Append = L & Left(Space(60), n) & S
48. End If
49. End Function