Results 1 to 14 of 14

Thread: How to Copy and Paste Registry Key?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    8

    Exclamation How to Copy and Paste Registry Key?

    Anyone know the code to copy key and paste into other key so that i can backup the important key to a safe place. I know it can be export. But i wanna try using Visual Basic .NET cos i just start learning this...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: How to Copy and Paste Registry Key?

    A .reg file is just plain text. You just need to determine exactly what the format is, then you can use a StreamWriter to create a new text file with a .reg extension.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    8

    Re: How to Copy and Paste Registry Key?

    I want to do it using visual basic .net...

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: How to Copy and Paste Registry Key?

    A StreamWriter is a .NET Framework class. Look it up!

    Once you know what the format of a .reg file looks like, you can write VB.NET code to read a registry key using the members of the Microsoft.Win32 namespace. You can then write more code to use a System.IO.StreamWriter object to create a new text file with a .reg extension and write the registry key data in the required format.

  5. #5
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: How to Copy and Paste Registry Key?

    Microsoft.Win32.RegistryKey class has excellent members to get the data you want and to set data.. examples are GetValue() and SetValue()
    You need to create two objects of RegistryKey type and you can read one and write to the other.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: How to Copy and Paste Registry Key?

    Why would you want to only backup a key and not the entire registry?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: How to Copy and Paste Registry Key?

    I just re-read the original post and I realised that it is asking how to copy a key to another location within the registry. This seems an odd request. How is one key any safer than another?

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    8

    Re: How to Copy and Paste Registry Key?

    Can this be done in a short and simple way... cos i am a beginner... i will be very happy if you show me the code.... thnx

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: How to Copy and Paste Registry Key?

    Why do you need to copy and paste it? Thats an unusual request.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: How to Copy and Paste Registry Key?

    Lookup the RegistryKey class in the help documentation and you'll get an example. Reading about the class will give you a better understanding than simply copying something one of us posts here. It's good practice at using the help system, too. It should become your best friend.

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How to Copy and Paste Registry Key?

    I can't think of a good reason to be doing that. I can however think of a few not so good reasons to want to try to do that.

  12. #12

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    8

    Re: How to Copy and Paste Registry Key?

    Anyone please show me the code for copy a registry key and paste into a registry key.. i just wanna try out... i know how to create key and delete key, i learn from MSDN but MSDN don have teach how to copy and paste... so any kind people please teach me..

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: How to Copy and Paste Registry Key?

    I believe some of us are concerned with the nature of this question and want to make sure its
    not against the Forums AUP

    Can you provide us with more details?

    Usually if the registry get corrupt, Windows will become unusable and how would you restore (paste) a
    registry key back in. Not to mention that a single key wouldnt help the corruption.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    8

    Re: How to Copy and Paste Registry Key?

    I recent have visit this web site http://www.winguides.com/registry/ i have learn quite a lot of thing inside... after that i start using Visual Studio .NET.. so i was thinking that i can use VB. net to do those setting inside registry(setting like disallowrun etc, i use this setting in my younger brother de windows account so he oni able to run game not other thing).... i want create a key call Explorer1 inside HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\. then i copy the content of Explorer to Explorer1... just wanna backup inside registry... just like everything is done inside registry...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width