|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error on deleting registry valuethe following code VB 2005 Express: Dim oReg As Microsoft.Win32.RegistryKey oReg = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") Try oReg.DeleteValue("AlcWzrd") Debug.Print("Successfully Delete Registry Key AlcWzrd") Catch ex As Exception Debug.Print(ex.ToString) Finally oReg.Close() End Try This fails with: A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll. Cannot write to the registry key. I'm running this under an admin account and I can add and remove this key in RegEdit. What am I doing wrong? <Brian8***@gmail.com> schrieb:
> My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") Replace "\\" with "\".-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> I've tried both ways.
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run") doesn't work either. On Nov 27, 9:01 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.at> wrote: Show quoteHide quote > <Brian8***@gmail.com> schrieb: > > > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")Replace "\\" with "\". > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> That OpenSubKey opens the key as read-only.
Try this: My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True ) Brian8***@gmail.com wrote: Show quoteHide quote > I've tried both ways. > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run") > doesn't work either. > > > > On Nov 27, 9:01 pm, "Herfried K. Wagner [MVP]" > <hirf-spam-me-h...@gmx.at> wrote: > > <Brian8***@gmail.com> schrieb: > > > > > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")Replace "\\" with "\". > > > > -- > > M S Herfried K. Wagner > > M V P <URL:http://dotnet.mvps.org/> > > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> In addition, I think you should call DeleteSubKey rather than
DeleteValue to delete a key. FishingScout wrote: Show quoteHide quote > That OpenSubKey opens the key as read-only. > > Try this: > > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", > True ) > > > Brian8***@gmail.com wrote: > > I've tried both ways. > > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run") > > doesn't work either. > > > > > > > > On Nov 27, 9:01 pm, "Herfried K. Wagner [MVP]" > > <hirf-spam-me-h...@gmx.at> wrote: > > > <Brian8***@gmail.com> schrieb: > > > > > > > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")Replace "\\" with "\". > > > > > > -- > > > M S Herfried K. Wagner > > > M V P <URL:http://dotnet.mvps.org/> > > > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Bingo! Thank you.
Show quoteHide quote On Nov 27, 9:58 pm, "FishingScout" <fishingsc***@comcast.net> wrote: > That OpenSubKey opens the key as read-only. > > Try this: > > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", > True ) > > Brian8***@gmail.com wrote: > > I've tried both ways. > > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run") > > doesn't work either. > > > On Nov 27, 9:01 pm, "Herfried K. Wagner [MVP]" > > <hirf-spam-me-h...@gmx.at> wrote: > > > <Brian8***@gmail.com> schrieb: > > > > > My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")Replace "\\" with "\". > > > > -- > > > M S Herfried K. Wagner > > > M V P <URL:http://dotnet.mvps.org/> > > > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
word automation vb.net
Arranging window screens on multi-monitor Desktop Re: Help needed in using FSO's, TextStreams, etc. --- Code Review and Advice requested listbox's SelectedIndexChanged keep fire better way to program than this? set refresh rate for an active browser window How broad should an interface be? Advice needed. File and Database Search Display Outlook Recipient Window from vb.net sqlDataReader does not return correct sorted data |
|||||||||||||||||||||||