Solved

VBScript - Importing Registry Keys

Posted on 2009-04-05
5
829 Views
Last Modified: 2012-08-13
Can somebody please tell me what mistake I am making with my Code?  I am making a simple call to back up 6 registry keys into 6 .reg files.  No matter what I try, I can only get 4 .reg files to be created:
printers.reg, network.reg, user_odbc.reg, machine_odbc.reg.
But I can never get the last two to work:
policies.reg, and internet.reg

I can't see what I am typing wrong with the code.
shell.run "regedit /e " & folder.path & "\printers.reg HKEY_CURRENT_USER\Printers\Connections\",0,True
 
shell.run "regedit /e " & folder.path & "\network.reg HKEY_CURRENT_USER\Network\",0,True
 
shell.run "regedit /e " & folder.path & "\policies.reg HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop\",0,True
 
shell.run "regedit /e " & folder.path & "\user_odbc.reg HKEY_CURRENT_USER\Software\ODBC\",0,True
 
shell.run "regedit /e " & folder.path & "\machine_odbc.reg HKEY_LOCAL_MACHINE\Software\ODBC\",0,True
 
shell.run "regedit /e " & folder.path & "\internet.reg HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\",0,True

Open in new window

0
Comment
Question by:aceklub97
  • 3
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 24072864
...because of the spaces - try this:
shell.run "regedit /e " & folder.path & "\printers.reg HKEY_CURRENT_USER\Printers\Connections\",0,True
 
shell.run "regedit /e " & folder.path & "\network.reg HKEY_CURRENT_USER\Network\",0,True
 
shell.run "regedit /e " & chr(34) & folder.path & "\policies.reg HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop\" & chr(34),0,True
 
shell.run "regedit /e " & folder.path & "\user_odbc.reg HKEY_CURRENT_USER\Software\ODBC\",0,True
 
shell.run "regedit /e " & folder.path & "\machine_odbc.reg HKEY_LOCAL_MACHINE\Software\ODBC\",0,True
 
shell.run "regedit /e " & chr(34) & folder.path & "\internet.reg HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\" & chr(34),0,True

Open in new window

0
 

Author Comment

by:aceklub97
ID: 24073081
sirbounty,
I switched out the keys:
shell.run "regedit /e " & chr(34) & folder.path & "\internet.reg HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\" & chr(34),0,True
 
shell.run "regedit /e " & chr(34) & folder.path & "\policies.reg HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop\" & chr(34),0,True

It know gives me an error message, "Cannot export polices.reg HKEY_CURRENT_USER\Software\Policies\Microsoft\Control Panel\Desktop\: Error opening the file.  There may be a disk or file system error."

When I put it back to what I had at first, the error goes away, but it doesn't copy.  

Any thoughts?
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 24073245
I dropped the quotes in the wrong spot - sorry...try this:
shell.run "regedit /e " & folder.path & "\printers.reg HKEY_CURRENT_USER\Printers\Connections\",0,True
 
shell.run "regedit /e " & folder.path & "\network.reg HKEY_CURRENT_USER\Network\",0,True
 
shell.run "regedit /e " & folder.path & "\policies.reg "  & chr(34) & "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop\" & chr(34),0,True
 
shell.run "regedit /e " & folder.path & "\user_odbc.reg HKEY_CURRENT_USER\Software\ODBC\",0,True
 
shell.run "regedit /e " & folder.path & "\machine_odbc.reg HKEY_LOCAL_MACHINE\Software\ODBC\",0,True
 
shell.run "regedit /e " & folder.path & "\internet.reg " & chr(34) & "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\" & chr(34),0,True

Open in new window

0
 

Author Closing Comment

by:aceklub97
ID: 31566813
that worked.  Thanks.  I'm not sure what what the spaceing different on this one, than the other ones...but I try this first next time I run into that issue.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24073851
Control Panel has a space, as does Internet Settings...the others are all run together (CurrentVersion) for example...

Thanx for the grade! :^)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

825 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