Solved

copy registry key to desktop

Posted on 2014-12-09
9
165 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 56

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 56

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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 56

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 56

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 56

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

Independent Software Vendors: 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!

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

626 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