Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Help and feedback with script searching the registry with regular expression

Reply
 
Old 04-09-2009   #1 (permalink)
L.


 
 

Help and feedback with script searching the registry with regular expression

Hi

Hope someone might help me out, since I'm stuck.
I have to search the registry of several computers to find if there is a
"PendingFileenameOperation" waiting. After some try and error, I've come up
with this solution where I read the registry and add all entries' to an
array, and then add each arrayitem to a string. I then intend to search the
string for a certain path. If the count is above 0 I have a
PendingFileRenameOperation" that requires a reboot.
My problem is as follows:

1) Is this the best way to solve this problem
2) I cant get my regular expression to work.

The code I've come up with is as follows:

Dim objShell
dim strPending, strSessionManager , strAllText
Dim arrFiles ''array containing files that are being renamed
Set objRegEx = CreateObject("VBScript.Regexp")
objRegEx.Global = True
objRegEx.Pattern = "C:\Norman" ''regular expression finding all entries
containing "c:\norman\"

strPending = "PendingFileRenameOperations" ''The regkey we're going to read
strSessionManager="HKLM\System\CurrentControlSet\Control\Session Manager\"
''the registry
Set objShell = CreateObject("WScript.shell")

arrFiles=objShell.Regread(strSessionManager & strPending) 'put all entries
in registry into the array
for each StrFile in arrFiles
strAllText= strAllText & " " & strFile ''add all entries into one long
string with spaces
next

set colMatches = objRegEx.Execute(strAllText)
if colMatches.count > 0 then
''Do something if there are keys in the given directory that is pending a
filerename operation.
end if

Any feedback would be greatly appreciated.

/Regards L.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Regular Expression help C# .NET General
Regular Expression for ../ .NET General
Help with a regular expression VB Script
regular expression help VB Script
Regular expression notes PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46