[VBScript] Recursive File Delete By Extension

'Delete all files with a specified file extensions in a given folder and all subfolders. (e.g. delete all files with extension "txt","doc" or "mp3" in folder "C:\Temp")


OPTION EXPLICIT
DIM strExtensionsToDelete,strFolder
DIM objFSO

'*********************************************
' Setup
'*********************************************
' Folder to delete files from (files will also be deleted from subfolders)
strFolder = "C:\Temp"
' A comma separated list of file extensions
' Files with extensions provided in the list below will be deleted
strExtensionsToDelete = "txt,doc,mp3"

'*********************************************

[C#] Get HardDrives Total Size & Free Space

...
...
using System.IO;
...
...
string MachineName = Environment.MachineName;
string strUptimeResult = string.Empty;
string strfltHDFreeSpaceUnit = string.Empty;
string strfltHDSizeUnit = string.Empty;
string strfltRAMSizeUnit = string.Empty;
string strNumberConv = string.Empty;
string strUnit = string.Empty;
...
...
public string ConvertValue(string fltNumberIni)
{
 if (Convert.ToDecimal(fltNumberIni) < 1024)
   {
   strUnit = " Bytes";
   }
 if ((Convert.ToDecimal(fltNumberIni) > 1024) & (Convert.ToDecimal(fltNumberIni) < 1048576))
   {
   strNumberConv = (Convert.ToDe

[C#] Get Total Physical Memory

//add reference to Microsoft.VisualBasic
//Solution Explorer --> References --> Right Click ---> Add Reference --> .Net --> Microsoft.VisualBasic
...
...
static float GetTotalMemoryInBytes()
  {
  return new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory;
  }
...
...
string strfltRAMSizeUnit = string.Empty;
float fltTotalMem = 0;
...
...
fltTotalMem = GetTotalMemoryInBytes();
if (fltTotalMem < 1024)
  {
  strfltRAMSizeUnit = " Bytes";
  }
if ((fltTotalMem > 1024) & (fltTotalMem < 1048576))
  {
  fltTotalMem = fltTotalMem / 1024;
  strfltRAMSizeUnit = " K

[C#] Get OS Name, Service Pack & Version

...
...
using Microsoft.Win32;
...
...
OperatingSystem osObj = Environment.OSVersion;
try
  {
  string MyKeyName = ("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
  string MyValueName = "ProductName";
  object MyObject = null;
  string MyValue = "";
  //Registry.GetValue returns an object:
  MyObject = Registry.GetValue(MyKeyName, MyValueName, null);
  if (MyObject != null)
     {
     //Get the string value of the object returned:
     MyValue = MyObject.ToString();
     MessageBox.Show(MyValue + " " + osObj.ServicePack);
     MessageBox.Show("Versi

[C#] Get CPU Specification

...
using System.Management;
...
//add reference to System.Management
//Solution Explorer --> References --> Right Click ---> Add Reference --> .Net --> System.Management
...
...
public static string GetCpuName()
   {
   try
     {
      ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
      foreach (ManagementObject queryObj in searcher.Get())
            {
            return queryObj["Name"].ToString().TrimStart();
             }
      }
    catch
       {
       return null;
       }
    return null;
   

[C#] Get Windows Uptime

...
...
string strUptimeResult = string.Empty;
strUptimeResult = Convert.ToString(Environment.TickCount / 86400000) + " Days, ";

strUptimeResult = strUptimeResult + Convert.ToString(Environment.TickCount / 3600000 % 24) + " Hours, ";

strUptimeResult = strUptimeResult + Convert.ToString(Environment.TickCount / 60000 % 60) + " Minutes, ";

strUptimeResult = strUptimeResult + Convert.ToString(Environment.TickCount / 1000 % 60) + " Seconds.";

MessageBox.Show("# UpTime : " + strUptimeResult);

[C#] Get Machine Name

...
...
string MachineName = Environment.MachineName;
...
...
MessageBox.Show("Machine Name: " + MachineName);
...
...

[C#] Get OS Architecture

...
...
int getOSArchitecture()
 {
 string pa = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
 return ((String.IsNullOrEmpty(pa) || String.Compare(pa, 0, "x86", 0, 3, true) == 0) ? 32 : 64);
 }
...
...
MessageBox.Show(getOSArchitecture().ToString() +"-Bit");
...
...

[C#] Get Windows Installation Date&Time

....
....
public static DateTime GetWindowsInstallationDateTime(string computerName)
{
  Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, computerName);
  key = key.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", false);
  if (key != null)
     {
     DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0);
     Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString());
     DateTime installDate = startDate.AddSeconds(regVal);
     return installDate;
     }
  return DateTime.MinValue

[C#] Get CPU Name

...
using System.Management;
...
//add reference to System.Management
//Solution Explorer --> References --> Right Click ---> Add Reference --> .Net --> System.Management
...
...
public static string GetCpuName()
{
 try
    {
     ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
     foreach (ManagementObject queryObj in searcher.Get())
             {
             return queryObj["Name"].ToString().TrimStart();
             }
     }
 catch
     {
      return null;
      }
 return null;
}
...
...
...
 pr
Syndicate content
http://www.google.com