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

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

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
Answered 11/27/2008 by: mqs
Senior Yellow Belt

Please log in to comment
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
Answered 11/27/2008 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity