I would have thought this was easy, but I can't find it. I need to find out what hardware the system has. For example CPU, ram, and harddrive. Is there any way to do this?
Thanks
Printable View
I would have thought this was easy, but I can't find it. I need to find out what hardware the system has. For example CPU, ram, and harddrive. Is there any way to do this?
Thanks
Update:
Ok I found I can get most, maybe even all of my information using System.Management. My question now is how can I figure out what tables I can query. Table may be the wrong turm but since this is like an SQL query I'm not sure what to call it. But I can search using SELECT * FROM Win32_OperatingSystem. Anyone know where I can look to find all the available options for Win32_...
Thanks
Update:
Found it. The 101 examples has it.
mpdeglau could u post the code here?
What are you looking for?
I Have to develop One of Each of the next 3 Categories.
Cat A (Files And Programs):
1. Get the Number Of Times a Specific Program has been used, and the time it was used.
2. Get The Content Details of a Specific Directory or Sub-Directory (Folders)
3. See All Hidden Files in a Specific Directory.
4. Hide All Files from an Specific Extension in a Directory
Cat B (HardDisk):
1. Get The Free and Ocupied Space of a HD
2. See How Many EXE files have been eliminated from a HD in a Specific Period Of Time
3. See All Content of a HD by File Type
4. Determine How Many times a HD has been desfragmented
Cat C (Remote Conexion and Internet):
1. Remotly Check the existence of a Floppy Disk or a CD in a PC
2. Limit the File Types that can be downloaded from Internet
3. Limit the File Size that can be downloaded from Internet
4. Get the most visited WebSites by an User
If Someone Can help me in AT LEAST one i will really really appreciate it:)
Here is code to get the hard drive size and the free space. You need to add a reference to System.Management. You will have a much easier time if you download and install the vb.net 101 examples. There are a ton of classes you can use in the query. Install it to any folder you want then search that folder for WMI and it will show you the example project for this.
VB Code:
Imports System.Managment Public Class Class1 Private HDToGet as String 'the drive you want to get the size of Private _HDSize as string Private _HDFreeSpace Public Sub New() End Sub Public Sub New(specificHD as string) 'sets the drive to get the size HDToGet = SpecificHD End Sub Public Property HDSize() As String Get getHardDriveTotalSpace(CaptureDrive) Return _HDSize End Get Set(ByVal Value As String) _HDSize = Value End Set End Property Public Property HDFreeSpace() As String Get getHardDriveFreeSpace(CaptureDrive) Return _HDFreeSpace End Get Set(ByVal Value As String) _HDFreeSpace = Value End Set End Property Private Function getHardDriveTotalSpace(ByVal capDrive As String) As String Dim HDSize As String Dim objOS = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") Dim objMgmt As ManagementObject For Each objMgmt In objOS.Get If objMgmt("Name").ToString = capDrive Then HDSize = objMgmt("Size").ToString End If Next _HardDriveSize = Format(HDSize / 1073741824, "0.00") End Function Private Function getHardDriveFreeSpace(ByVal capDrive As String) As String Dim HDSpace As String Dim objOS = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") Dim objMgmt As ManagementObject For Each objMgmt In objOS.Get If objMgmt("Name").ToString = capDrive Then HDSpace = objMgmt("FreeSpace").ToString End If Next _HDFreeSpace = Format(HDSpace / 1073741824, "0.00") End Function End Class
mpdeglau thx very much man
let me see now how that 101 examples work
Download Scriptomatic2 by the Microsoft team. It writes VBS as well as other languages to easily use WMI. It also emumerates all available options that you select from combo boxes.
mpdeglau
i used your code and it was very very helpful, it just had a couple of errors therefore im going to post the corrected code (the error where in variables and meaningless stuffs like that)
VB Code:
Imports System.Management Public Class Class1 Private HDToGet As String 'the drive you want to get the size of Private _HDFreeSpace As String Private _HardDriveSize As String Public Sub New(ByVal specificHD As String) 'sets the drive to get the size HDToGet = specificHD End Sub Public Property HDSize() As String Get getHardDriveTotalSpace(HDToGet) Return _HardDriveSize End Get Set(ByVal Value As String) _HardDriveSize = Value End Set End Property Public Property HDFreeSpace() As String Get getHardDriveFreeSpace(HDToGet) Return _HDFreeSpace End Get Set(ByVal Value As String) _HDFreeSpace = Value End Set End Property Private Function getHardDriveTotalSpace(ByVal capDrive As String) As String Dim HDSize As String Dim objOS = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") Dim objMgmt As ManagementObject For Each objMgmt In objOS.Get If objMgmt("Name").ToString = capDrive Then HDSize = objMgmt("Size").ToString End If Next _HardDriveSize = Format(HDSize / 1073741824, "0.00") End Function Private Function getHardDriveFreeSpace(ByVal capDrive As String) As String Dim HDSpace As String Dim objOS = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") Dim objMgmt As ManagementObject For Each objMgmt In objOS.Get If objMgmt("Name").ToString = capDrive Then HDSpace = objMgmt("FreeSpace").ToString End If Next _HDFreeSpace = Format(HDSpace / 1073741824, "0.00") End Function End Class