Solved

copy registry key to desktop

Posted on 2014-12-09
9
157 Views
Last Modified: 2014-12-14
Need vbscript that will copy a registry key to the desktop in .reg form.
Thanks ahead.
Troy
0
Comment
Question by:hardrock95
  • 5
  • 4
9 Comments
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 40489491
try something like this:

objShell.run "regedit /e C:\....\myreg.reg 'HKEY_CURRENT_USER\Software\VB and VBA Program Settings'"

just be carefull about " 

you may need something like"

objShell.run "regedit /e ""C:\...path_to_desktop...\myreg.reg"" 'HKEY_CURRENT_USER\Software\VB and VBA Program Settings'"
0
 

Author Comment

by:hardrock95
ID: 40489529
Do I need some sort of object shell definition and is the standard path to desktop c:\desktop?
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40489538
here it is:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "regedit /e ""C:\...path_to_desktop...\myreg.reg"" 'HKEY_CURRENT_USER\Software\VB and VBA Program Settings'"
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 51

Expert Comment

by:HainKurt
ID: 40489540
you can use this to find desktop

strDesktop = WshShell.SpecialFolders("Desktop")

then full code will be

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
WshShell.Run "regedit /e """ &  strDesktop  &"\myreg.reg"" 'HKEY_CURRENT_USER\Software\VB and VBA Program Settings'"
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40489589
here is working, tested sample:

dim WSHShell, strDesktop

Set WSHShell = WScript.CreateObject("WScript.Shell")
strDesktop = WSHShell.SpecialFolders("Desktop")

strDesktop = WshShell.SpecialFolders("Desktop")
strCmd = "regedit /e """ &  strDesktop & "\myreg.reg"" HKEY_LOCAL_MACHINE\SOFTWARE\HAINKURT"

WSHShell.Run strCmd

Open in new window

0
 

Author Comment

by:hardrock95
ID: 40489596
It runs, and I have tried other keys, but I cannot find myreg.reg anywhere on my computer.
I am assuming that is what I am looking for.  Do I need to create it first?
0
 

Author Comment

by:hardrock95
ID: 40489602
Last example appears to have worked.  I will let you know if there are issues.
Thanks.
Troy
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40489635
in the previous samples I used ' around reg path, which cause issues i guess... maybe we should use " instead of '

strCmd = "regedit /e """ &  strDesktop & "\myreg.reg"" HKEY_LOCAL_MACHINE\SOFTWARE\HAINKURT"

>>>

strCmd = "regedit /e """ &  strDesktop & "\myreg.reg"" ""HKEY_LOCAL_MACHINE\SOFTWARE\HAINKURT"""

if reg path has special characters (?) or spaces... if there is no space, we dont need any ' or " around it...
0
 

Author Closing Comment

by:hardrock95
ID: 40499099
Great help as always.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

810 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