As discussed in the comments, you don't need a VBS script to do this. Everything you do in your script file can be done in C#, using
Registry.GetValue[
^],
Registry.SetValue[
^], and
SendKeys.Send[
^].
The problem is that
SendKeys
is sending the input to your application's window, because that's the active application when you click the button. You either need to set the focus to the correct window before calling
SendKeys.Send
, or minimize your application's window to activate the previous window.