mystuff

Your IP Address is: 38.107.191.103
Last site update: 23 March 2009
You are visitor number: 

  home | wsname | wallpaper creator | delphi stuff | vb script stuff | other stuff | contact me

Google
Web Site
Here's a collection of Visual Basic (vb) Script functions I've collected over the years.

Services
   Check if a particular service is running

File System
   Delete a file
   Find a file if it's in the path
   Find the CDROM Drive
   Find CDROM Drive with Media
   Generate a filename and path for a working file in the %temp% directory
   Find the size of a file
   Find the location of PST files and log them in a SQL database

Network
   Renew a DHCP lease
   Ping a host (using WMI)
   Ping a host using the external ping.exe
   Convert an IP Address Mask to Slashed Notation
   Set a static IP address from a text file

Registry
   Search through the registry using recursion

Misc
   Including common functions and statement in your scripts
   Open the Control Panel Dialogue to the "Connections" option
   Convert a Binary File to a String
   Check if you're running on a Desktop or Laptop

Working With Data Files (INI, XML, SQL) files
   Using SQL to Generate a Self Incrementing Computer Naming System
   Read a Value from an INI File (GetINI)
   Write to an INI file (WriteINI)
   Read a whole section of an INI file
   Write a whole section to an INI file
   Read a value from an XML file

LDAP, AD, Exchange etc
   Get User Information from an Exchange 5.5 GAL
   Check to see if a User Account Exists in AD
   Get Members of an AD Group
   Update the Terminal Services Profile Path to point to a new Server
   Set Exchange 'Send As' and 'Receive As' Permissions


 Search through the registry using recursion

This script recurses though the registry from a given starting point, the example just displays the keys and their data type, you can modify this to search for specific data or whatever your need is.

Download the script or copy the example below:

Option Explicit

Const HKEY_CLASSES_ROOT   = &H80000000
Const HKEY_CURRENT_USER   = &H80000001
Const HKEY_LOCAL_MACHINE  = &H80000002
Const HKEY_USERS          = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005

Dim oReg : Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

RecurseRegistryKey HKEY_CURRENT_USER, "Control Panel"

Sub RecurseRegistryKey(ByVal sHive, ByVal sKey)
    Dim aSubKeys, sSubKey, iRC, aValueNames, aValueTypes, iI, sType
    'On Error Resume Next
    iRC = oReg.EnumValues(sHive, sKey, aValueNames, aValueTypes)
    If iRC = 0 And IsArray(aValueNames) Then
        For iI = LBound(aValueNames) To UBound(aValueNames)
            Select Case aValueTypes(iI)
                Case 1
                    sType = "REG_SZ"
                Case 2
                    sType = "REG_EXPAND_SZ"
                Case 3
                    sType = "REG_BINARY"
                Case 4
                    sType = "REG_DWORD"
                Case 7
                    sType = "REG_MULTI_SZ"
                Case Else
                    sType = "Unknown"
            End Select
            WScript.Echo sKey & "\" & aValueNames(iI) & " " & sType
        Next
    End If
    iRC = oReg.EnumKey(sHive, sKey, aSubKeys)
        If iRC = 0 And IsArray(aSubKeys) Then
            For Each sSubKey In aSubKeys
                If Err.Number <> 0 Then
                    Err.Clear
                    Exit Sub
                End If
                RecurseRegistryKey sHive, sKey & "\" & sSubKey
            Next
        End If
End Sub