Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 13th, 2008, 10:33 AM
lakshmilatest lakshmilatest is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 1 lakshmilatest User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 34 sec
Reputation Power: 0
WSH - Getting the system memory and hard disk space

Hi
I have the following requirement that I need to fetch the system memory from the system and needs to check whether it has minimum 512 MB. I have read that FileObject Can be used for that purpose. But it returns only Fixed , unknown , removable and CD ROM and not RAM. Please let me know what is the best way to fetch the system memory.

My Requirement is I need to check the minimum memory and hard disk size before pushing either the install script or upgrade script.

Please help me out to solve the issue ASAP. Your help is appreciated.Thanks.

Reply With Quote
  #2  
Old May 13th, 2008, 12:17 PM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
Click here for more information.
 
Join Date: Feb 2005
Location: Dreamland
Posts: 12,664 mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)mehere User rank is General 8th Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 4 Months 3 Weeks 5 Days 22 h 37 m 25 sec
Reputation Power: 1542
__________________
Come JOIN the party!!!

Quote of the Month:
Stupidity: Quitters never win, winners never quit, but those who never win AND never quit are idiots.

Questions to Ponder:
If man evolved from monkeys and apes, why do we still have monkeys and apes?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright© 2008 sbenj69

Reply With Quote
  #3  
Old May 14th, 2008, 09:37 AM
johnnyhk1 johnnyhk1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 johnnyhk1 User rank is Corporal (100 - 500 Reputation Level)johnnyhk1 User rank is Corporal (100 - 500 Reputation Level)johnnyhk1 User rank is Corporal (100 - 500 Reputation Level)johnnyhk1 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 55 m 22 sec
Reputation Power: 0
Try this

Quote:
Originally Posted by lakshmilatest
Hi
I have the following requirement that I need to fetch the system memory from the system and needs to check whether it has minimum 512 MB. I have read that FileObject Can be used for that purpose. But it returns only Fixed , unknown , removable and CD ROM and not RAM. Please let me know what is the best way to fetch the system memory.

My Requirement is I need to check the minimum memory and hard disk size before pushing either the install script or upgrade script.

Please help me out to solve the issue ASAP. Your help is appreciated.Thanks.


Insert the following code in your vbs script to find memory and drive space:

vb Code:
Original - vb Code
  1. Set colRAM = objWMIService.ExecQuery _
  2.     ("Select TotalphysicalMemory from WIN32_ComputerSystem")
  3.     For Each objRAM In colRAM
  4.     RAM = Round(objRAM.TotalPhysicalMemory/(1024*1024), 2) 'Show memory in MB
  5. If RAM < 512 Then
  6. WScript.Echo "Insufficient memory for installation"
  7. Else
  8. Set colDiskSp = objWMIService.ExecQuery _
  9.     ("Select * From WIN32_LogicalDisk")
  10.     For Each objDiskSp In colDiskSp
  11.     If Not IsNull(objDiskSp.size) Then
  12.     If objDiskSp.Description = "Local Fixed Disk" Then
  13.         DiskSpace = Round(objDiskSp.Size/(1024*1024*1024), 2) 'Show size in GB
  14.         DriveLetter = objDiskSp.DeviceID
  15.         FreeSpace = Round(objDiskSp.FreeSpace/(1024*1024*1024), 2) 'Show freespace in GB
  16. If FreeSpace < <required amount of freespace> Then
  17. WScript.Echo "Insufficient free disk space for installation"
  18. Else
  19. <run script to install>
  20. End If
  21. End If
  22. End If
  23. End If


Of course you'll need to tweak this for your environment, and you might only want the free space on the C: drive.

Last edited by mehere : May 14th, 2008 at 10:47 AM. Reason: added code tags ... please use them in the future when posting code

Reply With Quote
  #4  
Old May 14th, 2008, 10:01 AM
johnnyhk1 johnnyhk1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 johnnyhk1 User rank is Corporal (100 - 500 Reputation Level)johnnyhk1 User rank is Corporal (100 - 500 Reputation Level)johnnyhk1 User rank is Corporal (100 - 500 Reputation Level)johnnyhk1 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 55 m 22 sec
Reputation Power: 0
Quote:
Originally Posted by lakshmilatest
Hi
I have the following requirement that I need to fetch the system memory from the system and needs to check whether it has minimum 512 MB. I have read that FileObject Can be used for that purpose. But it returns only Fixed , unknown , removable and CD ROM and not RAM. Please let me know what is the best way to fetch the system memory.

My Requirement is I need to check the minimum memory and hard disk size before pushing either the install script or upgrade script.

Please help me out to solve the issue ASAP. Your help is appreciated.Thanks.


Here is a cleaned up script that should work for you:

vb Code:
Original - vb Code
  1. On Error Resume Next
  2.  
  3. Dim colRAM, colDiskSp, objRAM, RAM, objDiskSp
  4. Dim FreeSpace, objWMIService, strComputer
  5.  
  6. strComputer = "."
  7.  
  8. Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  9.  
  10.     'Find the amount of physical memory
  11. Set colRAM = objWMIService.ExecQuery _
  12.     ("Select TotalphysicalMemory from WIN32_ComputerSystem")
  13.     For Each objRAM In colRAM
  14.     RAM = Round(objRAM.TotalPhysicalMemory/(1024*1024), 2) 'Show memory in MB
  15. Next
  16. If RAM < 512 Then
  17. WScript.Echo "Insufficient memory to install application"
  18. Else
  19.  
  20. Set colDiskSp = objWMIService.ExecQuery _
  21.     ("Select * From WIN32_LogicalDisk")
  22.     For Each objDiskSp In colDiskSp
  23.     If objDiskSp.DeviceID = "C:" Then
  24.         FreeSpace = Round(objDiskSp.FreeSpace/(1024*1024*1024), 2) 'Show freespace in GB
  25.         If FreeSpace < 2 Then 'You would put the minimum amount of free space in GB here
  26.         WScript.Echo "Insufficient free space to install appliction"
  27.         Else
  28.         WScript.Echo "The application can be installed"
  29.     End If
  30. End If
  31. Next
  32. End If
Comments on this post
mehere agrees: nice one

Last edited by mehere : May 14th, 2008 at 10:47 AM. Reason: added code tags ... please use them in the future when posting code

Reply With Quote
  #5  
Old May 14th, 2008, 08:16 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Click here for more information.
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 729 Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 175254 Folding Title: Super Ultimate Folder - Level 1Folding Points: 175254 Folding Title: Super Ultimate Folder - Level 1Folding Points: 175254 Folding Title: Super Ultimate Folder - Level 1Folding Points: 175254 Folding Title: Super Ultimate Folder - Level 1Folding Points: 175254 Folding Title: Super Ultimate Folder - Level 1Folding Points: 175254 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Days 2 h 35 m 18 sec
Reputation Power: 351
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
Heh. I actually just wrote an article for ASP Free that addresses this very question. I should be submitting it in the very near future. I'll post back here when the article goes live.
__________________
Click the image if at any point you don't like my decision.

Scripting problems? Windows questions? Ask the Windows Guru!


Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > WSH - Getting the system memory and hard disk space


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway