WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   In VB Script Plattenplatz rausfinden (http://www.wcm.at/forum/showthread.php?t=62310)

mad 08.07.2002 16:25

In VB Script Plattenplatz rausfinden
 
:confused: Für ne Sicherheitsabfrage in einem VB Script wollt ich wissen, ob & wenn wie man den Platz auf einer Festplatte ( C: ) rausfindet um den dann weiter zu verarbeiten. Danke!

renew 08.07.2002 17:19

Hab ich nur jetzt schnell aus einem Buch raus kopiert...
Weiß aber nicht obs funkt - wennst es ausprobiert hast, schreib einfach mal. ;)

Code:

laufwerk = InputBox("Geben Sie den Laufwerksbuchstaben an!", "Laufwerk", _
"C:\")
ergebnis = FreeSpace(laufwerk)
if ergebnis<0 then
if ergebnis = -1 then
MsgBox "Es lag kein Datenträger im Laufwerk!",vbExclamation
elseif ergebnis = -2 then
MsgBox "Laufwerk " & laufwerk & " existiert nicht!",vbExclamation
end if
else
ergebnis2 = TotalSpace(laufwerk)
MsgBox "Freier Speicher auf Laufwerk " & _
laufwerk & ": "& FormatMB(ergebnis) & _
vbCr & "Speicherplatz insgesamt: "& _
FormatMB(ergebnis2), vbInformation
end if
function FreeSpace(lfw)
set fs = CreateObject _
("Scripting.FileSystemObject")
if fs.DriveExists(lfw) then
set lfwhandle = fs.GetDrive(lfw)
if lfwhandle.isReady then
FreeSpace = lfwhandle.FreeSpace
else
FreeSpace = -1
end if
else
FreeSpace = -2
end if
end function
function TotalSpace(lfw)
set fs = CreateObject("Scripting.FileSystemObject")
if fs.DriveExists(lfw) then
set lfwhandle = fs.GetDrive(lfw)
if lfwhandle.isReady then
TotalSpace = lfwhandle.TotalSize
else
TotalSpace = -1
end if
else
FreeSpace = -2
end if
end function
function FormatMB(bytes)
if bytes<1024 then
FormatMB = bytes & " Bytes"
elseif bytes<1024^2 then
FormatMB = FormatNumber(bytes/1024,2) & " KB"
elseif bytes<1024^3 then
FormatMB = FormatNumber(bytes/1024^2, 2) & " MB"
else
FormatMB = FormatNumber(bytes/1024^3, 2) & " GB"
end if
end function


mad 08.07.2002 22:37

Danke, daß probier ich sofort
 
;)

mad 08.07.2002 23:13

Ausprobiert: Nur 2 GB
 
Diese Routine ist wohl eine der alten in Windows: die kennt nur maximal 2GB - Platten. Aber als Sicherheitsabfrage, wenn es zu eng wird, ist das allemal geeignet - danke!:)

renew 09.07.2002 10:13

na immerhin weiß ich jetzt, dass es funkt, wenn ich sowas mal brauch.

Aber wundert mich, dass es auf 2GB limitiert ist, weil ich glaub, "alte Windosen" hatten ja noch keinen Scriptinghost....

mad 09.07.2002 10:43

Rätselhaft
 
ist das schon, aber ich denke es liegt daran, daß für den ScriptingHost keine extra Windows-Routinen 'eingebaut' wurden, nur der VBS-Interpreter wird in Windows dazugekommen sein. Und der greift auf die - in dem Fall - alte Routine von Windows zu (hab ME).

;) wie du schon sagtest, in der IT-Branche...

renew 09.07.2002 10:47

Habs grad bei mir ausprobiert (Win2k): bei mir schriebt er alles korrekt an. Dürft wirklich an der alten ME Runtime liegen. Weil ich hab 1,6GB frei und 10GB Platz auf der Platte. Bei dir wird er den Plattenplatz wahrscheinlich eben auf die 2GB begrenzt haben.

mad 09.07.2002 10:55

Das wird es sein
 
und dabei hat ME doch soviel von 2000 übernommen :lol:
die explorer.exe meint z.B. sie sei die gleiche wie in 2k
das abschauen blieb wohl aber bei der schickeren Optik

_m3 09.07.2002 13:12

http://msdn.microsoft.com/library/de...ofreespace.asp

Zitat:

When you use the AvailableSpace, FreeSpace, and TotalSize properties, the Drive object calls a Win32 function to perform the calculations. However, this function has a bug if you're using Win9x. The Win32 function truncates the amount of free space to 2GB.
http://www.winscriptingsolutions.com...ArticleID=7992


Alle Zeitangaben in WEZ +2. Es ist jetzt 11:04 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag