Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello i need to connect to a computer but with the registry.

i got this, but it just open regedit and then it makes nothing.



Private Sub Button1_Click_3(sender As Object, e As EventArgs) Handles Button1.Click


      System.Diagnostics.Process.Start("regedit.exe")

      System.Threading.Thread.Sleep(2000)

      SendKeys.Send("{%}")
      SendKeys.Send("{ENTER}")
      SendKeys.Send("{DOWN}")
      SendKeys.Send("{DOWN}")
      SendKeys.Send("{DOWN}")
      SendKeys.Send("{DOWN}")
      SendKeys.Send("{ENTER}")
      SendKeys.Send(Hostname.Text)
      SendKeys.Send("{ENTER}")

  End Sub


What I have tried:

code below

ALT, ENTER, DOWN, DOWN, DOWN, DOWN, Hostname.text, ENTER

dosnt work
Posted
Updated 17-Jun-16 2:36am

First off, why would you want to do that? Retrieve the Registry entry properly and use the value it returns: Registry.GetValue Method (String, String, Object) (Microsoft.Win32)[^]
Secondly, did you really expect that to work? The first thing Regedit will do is kick up UAE to get user permission to edit the registry: and you can't give that yourself...
 
Share this answer
 
I think your SendKeys isn't opening the menu properly. Looks like you're opening the File menu and tabbing downwards to menu item 4 (Connect Network Registry).

Some information on SendKeys here (MSDN) and here (Stack Overflow)

You are sending ALT (which as a keystroke will highlight the menu) then ENTER (which should then open the first menu). Try instead to open the file menu in one operation by sending ALT+F

So instead of
C#
SendKeys.Send("{%}")
SendKeys.Send("{ENTER}")

try
C#
SendKeys.Send("%{f}")


Just one more thing - can you clarify "doesn't work"? Does the application open? Does the menu highlight but not select? Does the menu appear at all? I offer a solution to what I *think* might be the problem but your question is a little unclear.

Good luck,
Glen.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900