Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

copy registry key to desktop

Posted on 2014-12-09
9
Medium Priority
?
167 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 59

Accepted Solution

by:
HainKurt earned 2000 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 59

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 59

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 59

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 59

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

719 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