Detect Registry Keys and Values

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Detect Registry Keys and Values

Post by JRL » Wed Dec 07, 2005 4:01 pm

Macro Scheduler currently has four registry related commands that I'm aware of.
- RegistryDelKey
- RegistryDelVal
- RegistryReadKey
- RegistryWriteKey

Would it be possible to have two new commands. One command to create a list of subkeys within a specified key and a second command that can create a list of values within a specified key. Maybe called:
- RegistryReadKeyList
- RegistryReadValList

- OR -

Does anyone know of a utility that can work silently with Macro Scheduler to accomplish this task?

Thanks for listening,
Dick

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Dec 07, 2005 9:36 pm

Seek and Ye shall find....

Mr Hansen answered my question 2 years before I asked it. He is so talented....:wink:

http://www.mjtnet.com/forum/viewtopic.p ... t=registry

Thank you,
Dick

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Wed Dec 07, 2005 9:39 pm

Haven't had the need to do this but it could be done using WScript.Shell.
Best Wishes,
Monkster

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Dec 07, 2005 10:20 pm

Thanks for the response Monkster.

Please don't spend any time writing something in VB unless its something that sounds like fun. The regedit command line solution works quickly, silently and is something I can understand.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Dec 09, 2005 3:50 pm

Took a couple of days before I was able to start working with this. This is what I've discovered this morning.

The regedit command line output that was described in this post:

http://www.mjtnet.com/forum/viewtopic.p ... t=registry

does not output a text file that is readable by Macro Scheduler. The file looks normal in notepad but notepad must have been written to accept .REG files and display them as regular text files. In reality, (and what notepad does not display) the first two characters of the file are ASCII character 255 and ASCII character 254. ReadLn and ReadFile see these characters and stop reading any more of the file. Additionally, throughout the .REG file, alternating characters are ASCII character 000 which ReadLn and ReadFile do not read.

So, I guess I jumped for joy too soon. If it's possible, I would again like to see a Macro Scheduler command that can list the contents of a specified registry key OR allow Macro Scheduler to import the full range of ASCII characters.

I've put this into BugTracker as a feature request.

Thanks for listening,
Dick

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Dec 09, 2005 6:10 pm

Hello Dick.....

I have no answer right now, but maybe this will help:

I believe that REG files are not "text" files. They use Unicode and UTF8 BOM formats. So, if you can find a text editor that handles Unicode, perhaps you can read and edit in that utilitly and have Macro Scheduler deal with the result.

I use Textpad and I created a "REG" class for dealing with these files. Can open, edit , and save as REG files. But you can do that in Notepad now, so this is probably not going to help. It sounds like you are trying to avoid using something besides Macro Scheduler.

TextPad does have its own limited macro tools, but I have no use for them, they cannot be written, or edited, only recorded! But I used TextPad and MacroScheduler together as a team for many tasks. Use one for "text editing", including sorting, and Regular Expressions, and use Macro Scheduler for running for all the macros needed to automate the processes.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Dec 09, 2005 7:35 pm

Thanks Bob,

For now I'm using an old DOS util change.exe that will let me convert the unwanted characters to nul. The downside is that I'm using a utility that might be but probably is not on other's computers. I would have that same issue with a text editor. Also, I'm hoping to write this to run silently in the background. Actually, without that requirement notepad could be used. Simply open the file in notepad, then copy all to the clipboard, GetClipBoard in macro scheduler and all of the extra non-text characters are gone.

What I'm hoping to accomplish with this is a utility that will detect new program installations. If I can search through specific registry keys and compare the results to a baseline, I can send myself an email whenever one of my clients has new software installed upon it. Note that my plan is merely informative. I still will walk to the machine and determine what is happening before taking any drastic measures.

Thanks for the replys,
Dick

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Dec 09, 2005 7:42 pm

Don't know if it helps but there are some other registry command line tools http://www.chaminade.org/MIS/Articles/RegistryEdit.htm

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Dec 09, 2005 8:04 pm

Um, if you want to read the file in as a text file you need to export it as an ascii text file:

REGEDIT /E:A filename [regpath]

/E:A exports to ascii text ....

Or, even better, you can get a list of registry values using good old vbscript:


VBSTART

Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Function GetValueList(Root,RegPath)
set objRegistry = GetObject("winmgmts://./root/default:StdRegProv")
Dim lRC
Dim sKeys()

On Error Resume Next
lRC = objRegistry.EnumValues(Root, RegPath, sKeys, iTypes)

If (lRC 0) or (Err.Number 0) Then
GetValueList = "Error"
Else
GetValueList = join(sKeys,vbCrLf)
End if
On Error goto 0
End Function

VBEND

Let>Path=Software\Microsoft\Windows\CurrentVersion\Themes
VBEval>GetValueList(HKEY_LOCAL_MACHINE,"%Path%"),valuelist
Separate>valuelist,CRLF,vals
Let>k=1
Repeat>k
Let>thisval=vals_%k%
RegistryReadKey>HKEY_LOCAL_MACHINE,Path,thisval,data
MessageModal>%thisval% = %data%
Let>k=k+1
Until>k=vals_count


The VBScript function GetValueList returns a CRLF delimited list of values in the given root and path. This example then Separates that and loops through each one and gets the associated data and displays the value=data in a message box.

This one enumerates XP themes. Change Root and Path to suit what you want to get ...
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Dec 09, 2005 8:31 pm

Thanks Marcus,

Regedit /e is what was suggested in Bob's post from 2003. The result is not a DOS text file. It contains characters outside of the ASCII subset that can be read and manipulated by Macro Scheduler. The exact line as posted by Bob:
Run Program>REGEDIT /E c:\temp\Testfile.REG "HKEY_CURRENT_USER\Software\MJTNET\
I will try your vbscript, see how it works and report back.

Thank you,
Dick

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Dec 09, 2005 8:33 pm

I know. But read my post again. I said:

Regedit /e:a

/e:a outputs in ascii.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Dec 09, 2005 8:56 pm

:)
I actually tried /E: thinking the colon might be magic.
"A filename" appeared to be a filename to be created. Then I apparently glossed over your next line.

"Regedit /e:a"

Couldn't get much more definitive than that.

I'm sorry I didn't catch on. Everyone knows "A" is for ASCII.
Thanks for the clarification, and don't feel bad about laughing..... I am.


Tried it and it works


Thanks,
Dick

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts