VBS Cheat Sheet: Difference between revisions
Jump to navigation
Jump to search
(Created page with " 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 objRegE...") |
No edit summary |
||
| Line 23: | Line 23: | ||
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ | Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ | ||
strComputer & "\root\default:StdRegProv") | strComputer & "\root\default:StdRegProv") | ||
strKeyPath = "SOFTWARE\Wow6432Node\ | strKeyPath = "SOFTWARE\Wow6432Node\domain\ScriptingHost\EIU\Dailyqueue" | ||
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys | objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys | ||
For Each Subkey in arrSubKeys | For Each Subkey in arrSubKeys | ||
Latest revision as of 15:29, 10 December 2021
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