Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB .net 2008 registry entry problem

Status
Not open for further replies.

bonifale

Programmer
Sep 4, 2003
74
GB
Morning all

I'm going mad here. I have created a registry value to run an exe at login...

My.Computer.Registry.SetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "GPIBControl", "C:\Program Files\GPIB Controller\GPIB Control.exe")

That works just fine but does anybody know how I can delete it?

I've tried..

My.Computer.Registry.CurrentUser.DeleteValue("GPIBControl")

and

My.Computer.Registry.CurrentUser.DeleteValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\GPIBControl")

to no avail. It returns a "No value exists with that name" error.

Any help much appreciated.


The actual function is pasted below.



Function ToggleRunAtLogin()

Dim Result As String
Try
Result = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "GPIBControl", Nothing)

If Result = Nothing Then
MsgBox("Run at login enabled")
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "GPIBControl", "C:\Program Files\GPIB Controller\GPIB Control.exe")
Else
MsgBox("Run at login disabled")
My.Computer.Registry.CurrentUser.DeleteValue("GPIBControl")
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try

End Function

 


Oh rats.....

Usual thing! worked it out after I posted.

The solution


My.Computer.Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue("GPIBControl")



Thanks anyway
Les....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top