ændre vbs script
hej.Jeg har fået til opgave at ændre dette script til at vise hvor meget en mappe fylder istedet for et drev men ved ikke lige hvordan da jeg er ny i vbs, så forslag modtages gerne.
scriptet
Option Explicit
Const cVBS = "DiscFree.vbs"
Const cDRV = "x:"
Dim objWMI
Set objWMI = GetObject("winmgmts:")
Dim objGET
Set objGET = objWMI.Get("Win32_LogicalDisk.DeviceID='" & cDRV & "'")
Dim sizeKB
sizeKB = objGET.size/1024
sizeKB = FormatNumber(Round(sizeKB),0)
Dim sizeMB
sizeMB = objGET.size/1048576
sizeMB = FormatNumber(Round(sizeMB,2),2)
Dim sizeGB
sizeGB = objGET.size/1073741824
sizeGB = FormatNumber(Round(sizeGB,2),2)
Dim freeKB
freeKB = objGET.FreeSpace/1024
freeKB = FormatNumber(Round(freeKB),0)
Dim freeMB
freeMB = objGET.FreeSpace/1048576
freeMB = FormatNumber(Round(freeMB,2),2)
Dim freeGB
freeGB = objGET.FreeSpace/1073741824
freeGB = FormatNumber(Round(freeGB,2),2)
Dim result
result = "No disk in drive or disk error!"
If freeGB < 28 Then
result = "Disk size:^|= " & sizeGB & " GB^^" _
& "Free space:^|= " & freeGB & " GB^^"
result = Replace(result,"^",vbCrLf)
result = Replace(result,"|",vbTab)
sendmail "x@x.dk", "cc", "bcc", "x@x.dk", "Server: xxx Kritisk lav diskplads på x-drev", "Drive " & cDRV & vbCrLf & result, "format", "importance", "attachments"
End If
' MsgBox result, vbOKOnly, "Drive " & cDRV
function sendmail(recipients, cc, bcc, from, subject, body, format, importance, attachments)
dim objMessage
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = subject
objMessage.From = from
objMessage.To = recipients
objMessage.TextBody = body
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "snowdrop"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update()
objMessage.Send()
set objMessage = nothing
end function
Wscript.Quit