Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing reg-files into HKCU

Status
Not open for further replies.

nogarap

Technical User
Jun 22, 2004
99
GB
Hi,
I hope someone can help me, or point out a mistake. I've got a worrying feeling I'm missing something really stupid here.
I'm trying to import some registry values in a logon script. These are the values I want to import:
*********contents of reg file***************************
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoComplete]
"Append Completion"="no"
"AutoSuggest"="no"

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"FormSuggestPasswords"=dword:00000001
"FormSuggest"=dword:00000001
"History"=dword:00000001
**********end of reg file****************************

When I add this to the logon scripts, using the regedit /s command, I get an error:
"Cannot import XXX.reg. Not all data was successfully written to the registry. Some keys are open by the system or other processes"

In our logon scripts we use another example of importing a reg key. This works without any problems.
We import this value:
***********working reg file value******************
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
"Favorites"=hex(2):48,00,3a,00,5c,00,46,00,61,00,76,00,6f,00,72,00,69,00,74,00,\
65,00,73,00,00,00
***********************************************************

So, what's the difference between the 2 scenarios? FWIW, the working reg values redirect users 'My Docs' to their H: (home) drive, and the non-working one is to clear autocomplete in typing URLs in IE, and clearing autocomplete in Google.
Hope somebody can suggest something, otherwise tomorrow will be spent learning about ADM files!
Many thanks in advance
 
A quick sample might help:
Code:
Set WSHShell = CreateObject("WScript.Shell")
Path = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoComplete\"
WshShell.RegWrite Path & "Append Completion", "No" ,"REG_SZ"

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Hi Mark,

Thanks for the reply, and the pointers. I'm afraid I might need more than a quick sample!
I followed your example above, and used it to do the IE autocomplete. I was stuck on the IE/Control Panel key though. I spent a lot of time last week fiddling with this, and it seems to be working this morning. One question I have is, when I use the PATH= statement, will it create any keys that are mentioned in the path that don't already exist, or do I have to create the keys, and then manipulate them on a later line?

This is the one I've got, which I need to test further. I've created a file, regtest.vbs, and in the logon script, I got 'cscript regtest.vbs' that should run the script for the relevant group.
*********************************************************
Set WSHShell = CreateObject("WScript.Shell")
Path = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoComplete\"
WshShell.RegWrite Path & "Append Completion", "No" ,"REG_SZ"
WshShell.RegWrite Path & "Autosuggest", "No" ,"REG_SZ"

Path = "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\"
WshShell.RegWrite Path & "FormSuggestPasswords", 1 ,"REG_DWORD"
WshShell.RegWrite Path & "FormSuggest", 1 ,"REG_DWORD"
WshShell.RegWrite Path & "History", 1 ,"REG_DWORD"
*********************************************************

Really appreciate your help on this.

Many thanks

Gaz
 
You got it right nogarap.

If a key does not exist you need to create it first.

If you wish to include error checking then what you would normally do is turn on "On Error Resume Next."

You would then try to read the key and check for an error. like this:

If err.number <> 0 Then
'Reg key does not exist, add code to create it
End If

You can only check the error number if you enable "On Error Resume Next."

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
You might also want to check out my login script FAQ. faq329-5798

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Mark,

thanks for your great help on this. I changed jobs just after this, and this was the last thing on my mind. No more login script headaches for me for a while I hope!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top