Search code examples
vb.netvisual-studioregistryregedit

execute registry script from vb.net


I am trying to work for an application where i need to embed registry code in my program. Basically this is a Windows App.

My registry code is

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell]
"icon"=""
"Position"="Bottom"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell]
@="system.exe -L"

This code is stored in a registry file. All i need to do is invoke this script on an event handler say button_click.

Options i have is write this code as a string and execute this string.. or simply have a collection of *.reg files which i may execute on button_click.

I understand my app requires UAC, and i would be giving that permission for my app in App Manifest.

Can anyone pls suggest me how to execute registry file (.reg) stored placed in a folder


Solution

  • Use Process.Start with a ProcessStart.UseShellExecute = True