[VBScript] Recursive File Delete By Extension
Submitted by SuperAmir on Tue, 09/06/2011 - 11:12.'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"
'*********************************************
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"
'*********************************************
»
- Add new comment
- Read more
- 140 reads
[C#] Get HardDrives Total Size & Free Space
Submitted by SuperAmir on Wed, 04/13/2011 - 17:12....
...
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
...
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
»
- Add new comment
- Read more
- 218 reads
[C#] Get Total Physical Memory
Submitted by SuperAmir on Wed, 04/13/2011 - 11:35.//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
//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
»
- Add new comment
- Read more
- 211 reads
[C#] Get OS Name, Service Pack & Version
Submitted by SuperAmir on Mon, 04/11/2011 - 17:18....
...
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
...
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
»
- Add new comment
- Read more
- 206 reads
[C#] Get CPU Specification
Submitted by SuperAmir on Mon, 04/11/2011 - 16:44....
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;
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;
»
- Add new comment
- Read more
- 172 reads
[C#] Get Windows Uptime
Submitted by SuperAmir on Mon, 04/11/2011 - 16:33....
...
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);
...
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);
»
- Add new comment
- 163 reads
[C#] Get Machine Name
Submitted by SuperAmir on Mon, 04/11/2011 - 16:23....
...
string MachineName = Environment.MachineName;
...
...
MessageBox.Show("Machine Name: " + MachineName);
...
...
...
string MachineName = Environment.MachineName;
...
...
MessageBox.Show("Machine Name: " + MachineName);
...
...
»
- Add new comment
- 155 reads
[C#] Get OS Architecture
Submitted by SuperAmir on Mon, 04/11/2011 - 16:22....
...
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");
...
...
...
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");
...
...
»
- Add new comment
- 169 reads
[C#] Get Windows Installation Date&Time
Submitted by SuperAmir on Mon, 04/11/2011 - 16:12.....
....
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
....
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
»
- Add new comment
- Read more
- 158 reads
[C#] Get CPU Name
Submitted by SuperAmir on Wed, 04/06/2011 - 11:56....
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
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
»
- Add new comment
- Read more
- 162 reads