0

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

1 Answer 1

0

Use Process.Start with a ProcessStart.UseShellExecute = True

Sign up to request clarification or add additional context in comments.

4 Comments

will it run external registry files ?
yes, it will run external .reg files. Look up Process.Start on MSDN
but i am still having a problem.. the application is giving a registry file prompt every time. .
That's not a problem - that's by design. Opening a .reg file launches RegEdit.exe, which will always prompt the user before importing. Its to keep the user from falling victim to some crackhead software that likes to run arbitrary reg files. If you don't like the prompt then you need to look into modifying the registry via code (See Microsoft.Win32 namespace).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.