Skip to main content

VB script to find the Disk Space

Option Explicit


const strReport="c:\output.txt"
const sFile ="c:\input.txt"


Dim objWMIService, objItem, colItems
Dim strDriveType, strDiskSize, txt


Dim oFSO, oFile, sText,strComputer
Set oFSO = CreateObject(“Scripting.FileSystemObject”)


Dim objFSO,objTextFile
Set objFSO = createobject(“Scripting.FileSystemobject”)
Set objTextFile = objFSO.CreateTextFile(strReport)



If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
 Do While Not oFile.AtEndOfStream
  sText = oFile.ReadLine
   If Trim(sText) <> “” Then
          strComputer=sText
              Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)
              Set colItems = objWMIService.ExecQuery(“Select * from Win32_LogicalDisk WHERE DriveType=3”)
             txt = sText & vbtab & “Drive” & vbtab & “Size” & vbtab & “Used” & vbtab & “Free” & vbtab & “Free(%)” & vbcrlf
        For Each objItem in colItems

             DIM pctFreeSpace,strFreeSpace,strusedSpace

             pctFreeSpace = INT((objItem.FreeSpace / objItem.Size) * 1000)/10
       strDiskSize = Int(objItem.Size /1073741824) & “Gb”
       strFreeSpace = Int(objItem.FreeSpace /1073741824) & “Gb”
       strUsedSpace = Int((objItem.Size-objItem.FreeSpace)/1073741824) & “Gb”
       txt = txt & vbtab & vbtab & objItem.Name & vbtab & strDiskSize & vbtab & strUsedSpace & vbTab & strFreeSpace & vbtab & pctFreeSpace & vbcrlf


        Next


*for getting Updates / if you are liking the posts and if this is useful Please follow the blog*
   
     

Comments

Popular posts from this blog

Encryption and Decryption functions for Java

    public static String encrypt(String key, String initVector, String value) {         try {             IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");             Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");             cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);             byte[] encrypted = cipher.doFinal(value.getBytes());             System.out.println("encrypted string: "                     + Base64.encodeBase64String(encrypted));             return Base64.encodeBase64String(encrypted);         } catch (Exception ex) {   ...

Disabling DEP(data Excecution prevention) for third party softwares in windows

1.go to system properties. 2.go to Advanced system settings . 3. go to Advance tab ,performance settings,Data execution prevention tab make sure u have selected 1st option as highlighted in screenshot.after making changes you must restart system

java function to write into sql database from java

public static void runsql(String Q)   {     try     {       // create a mysql database connection           String myUrl = "jdbc:mysql://localhost:3306/firewall?zeroDateTimeBehavior=convertToNull";       Class.forName("com.mysql.jdbc.Driver");       Connection conn = DriverManager.getConnection(myUrl,"root", "password");       if (conn != null) {     System.out.println("Connected"); }       Statement st = conn.createStatement();             st.executeUpdate(Q);       conn.close();     }     catch (Exception e)     {       System.err.println("Got an exception!");       System.err.println(e.getMessage());     }   }