/build/static/layout/Breadcrumb_cap_w.png

VB script to check space

Help me to get VB script to check D:\ for 5 GB free space and 200 MB for C:\ before installation..

thanks.

0 Comments   [ + ] Show comments

Answers (2)

Posted by: mqs 15 years ago
Senior Yellow Belt
0
I have the script now... which checks of C:\

Option Explicit
Dim objWMIService, objDisk, colDisks , FREESPACE_SYSTEM, FREESPACE_MB , FREESPACE_GB , INT_FREESPACE
Dim strLogonUser, strComputer , WshShell
on error resume next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DeviceID = 'C:'")
For Each objDisk in colDisks
FREESPACE_SYSTEM = (objDisk.FreeSpace)
Next
FREESPACE_MB = FREESPACE_SYSTEM/(1024*1024)
INT_FREESPACE=int(FREESPACE_MB)
FREESPACE_GB = FREESPACE_MB/(1024)

'msgbox INT_FREESPACE
msgbox FREESPACE_mb

WScript.Quit
Posted by: anonymous_9363 15 years ago
Red Belt
0
There is a separate 'Scripting' forum on AppDeploy which is where your post & reply ought to be.

I imagine a moderator will move the thread there at some point.

Notes:
- Please use the CODE tag when posting code (or any lengthy tracts of text). It can be accessed by clicking the '<%' button in the 'Reply to Message' window
- Like beginner's scripts, yours has no error-trapping. When programming, always assume the worst and code accordingly:Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
If Err.Number <> Then '// or you could use 'If Not IsObject(objWMIService) Then
'// Display an appropriate error message
'// then exit the Sub/Function/Script
End If
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DeviceID = 'C:'")
If Err.Number <> Then '// or you could use 'If Not IsObject(objWMIService) Then
'// Display an appropriate error message
'// then exit the Sub/Function/Script
End If
and so on
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ