[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VBScript - Importing Registry Keys

Posted on 2009-04-05
5
Medium Priority
?
849 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

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

656 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