VBS Cheat Sheet
Date format using a trailing "0"
strDayOfMonth = Right("0" & Day(Date()),2) strMonth = Right("0" & Month(Date()),2) strYear = Right (Year(Date()),4)
Regex
Set objRegEx = CreateObject("VBScript.RegExp") objRegEx.Global = True objRegEx.IgnoreCase = True objRegEx.Pattern = "Sti" strText="Test Sting" Set colMatches = objRegEx.Execute(strText) wscript.echo colMatches.Count
Enumerate regitry subkeys
Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Wow6432Node\domain\ScriptingHost\EIU\Dailyqueue" objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys For Each Subkey in arrSubKeys Wscript.Echo Subkey Next
Print and CR only
Wscript.StdOut.Write Now & vbCR