Solved

usuing vbs how can i read a binary reg value from the HKEY_USERS registry and rename the key so that i can import different keys?

Posted on 2008-10-07
2
744 Views
Last Modified: 2013-11-13
Morning, I am looking to pin icons to the desktop for 10,000+ users as part of the office 2007 roll out, currently office icons are built in to the standard image build which will be removed at the end of the year, i have found the registry keys that contain the settings for every user profile on the machine under HKEY_USERS, i would normally add the registry key import to the logon script but as we are doing a stagered roleout of office i thought a wsh/vbs script may do the trick.

I have a script that installed office 2007 and then adds additional reg keys however it will not add them to every users profile on the machine so i was hoping to write something that would loop though all they sid's and add the keys how ever when i have tried i am able to read the first key and store that as a variable but when i try to output it to another key to create a backup before i go ahead and change keys i get a data mismatch.

Is there a way to read and write binary reg keys in a script that will loop through all the sid's and change the keys or do i need to come up with a different approach?
Set Shell = CreateObject("WScript.Shell")

arr = Shell.RegRead("HKEY_USERS\S-1-5-21-1008850429-2325668040-1177597070-84490\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage\favorites")
 

a=arr

b=arr
 

For I = LBound(arr) To UBound(arr)

a(I) = CInt(arr(I))

b(I) = Hex (CInt(arr(I)))

Next
 

Wscript.Echo "The registry key name's decimal value is", Join(a),",", "the hex value is", Join(b),"."

msgbox Join(a),,"The decimal value is"

msgbox Join(b),,"The hexadecimal value is"

Open in new window

0
Comment
Question by:mdlister
  • 2
2 Comments
 

Author Comment

by:mdlister
ID: 22657856
ok so i have been doing some work on this and so far have found a few examples of how to get this done envolving taking the key and creating a temp reg key then importing it to the machine here is the code, does anyone know how to get it to loop through all the HKEY_USERS Sid's that arent system accounts and apply the key?
Const st_TEMPFILE = "temp.reg"

'Dems the dims

Dim key 

Dim oFS

Dim txtStream

Dim strComputer

Dim WSHShell
 

'Set WSH

Set WSHShell = WScript.CreateObject("WScript.Shell")
 

Set Shell = CreateObject("WScript.Shell")

arr = Shell.RegRead("HKEY_USERS\S-1-5-21-1008850429-2325668040-1177597070-84490\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage\favorites")

a = arr

For I = LBound(arr) To UBound(arr)

a(I) = Hex (CInt(arr(I))) + ","

If a(I) = "0" Then

a(I) = "00,"

End if

Next
 

'Create the temporary reg file

Set oFS = CreateObject("Scripting.FileSystemObject")

Set txtStream = oFS.CreateTextFile(st_TEMPFILE,true)

txtStream.WriteLine("Windows Registry Editor Version 5.00")

txtStream.WriteLine("")

txtStream.WriteLine("[HKEY_LOCAL_MACHINE\SOFTWARE\Description\Microsoft\RPCUUID Temporary Data]")

txtStream.WriteLine("@=" & Chr(34) & Chr(34))

txtStream.WriteLine(chr(34) & "BackupKey" & chr(34) & "=" & "hex:" & Join(a,""))

txtStream.Close
 

'Execute regedit /s (silent) against the temporary .reg file

WshShell.Run "regedit " & st_TEMPFILE, 1, true

Set WshShell = Nothing
 

'Delete the temporary .reg file (If you want it to remain for your review comment out the follwoing line)

oFS.DeleteFile st_TEMPFILE

Set oFS = Nothing
 

'Echo to let me know we've reached the end of the script, and then a Quit

WScript.Echo("Process Complete")

WScript.Quit(0)

Open in new window

0
 

Accepted Solution

by:
mdlister earned 0 total points
ID: 22659201
right ok i have managed to get the script to do what i want and write the binary reg keys but how would i loop it through the SID's?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 Tips For Quarter Milers: A Sprinter's Understanding of Agile Software Development Two years ago, I wrote a blog entry about Agile software development (http://www.experts-exchange.com/blogs/mwvisa1/B_1770-Agile-Software-Development.html). At th…
When we talk about DevOps toolchains, I sometimes wonder how many people really get what we’re talking about. I don’t know if it’s just semantics or tone or something else, but sometimes I think it just sounds like buzzword sausage. So it’s always …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now