Solved

copy registry key to desktop

Posted on 2014-12-09
9
160 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
[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
  • 5
  • 4
9 Comments
 
LVL 51

Accepted Solution

by:
Huseyin KAHRAMAN 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:Huseyin KAHRAMAN
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:Huseyin KAHRAMAN
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:Huseyin KAHRAMAN
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:Huseyin KAHRAMAN
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Plain Text Editor for iPad 6 105
sp_configure 'external scripts enabled', 1; 7 107
some keys in my laptop is not working. any suggestion 6 47
Programming Codes 2 39
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn different types of Android Layout and some basics of an Android App.
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 …

762 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