Solved

VBScript - Importing Registry Keys

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

867 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

21 Experts available now in Live!

Get 1:1 Help Now