?
Solved

VBScript - Importing Registry Keys

Posted on 2009-04-05
5
Medium Priority
?
841 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

770 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