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.
thanks.
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
mqs
15 years ago
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
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
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:
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.
so that the conversation will remain readable.