Solved

VBScript - Importing Registry Keys

Posted on 2009-04-05
5
826 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

12 Experts available now in Live!

Get 1:1 Help Now