473,503 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error on deleting registry value

I'm doing something wrong. I'm trying to delete a registry value with
the following code VB 2005 Express:

Dim oReg As Microsoft.Win32.RegistryKey
oReg =
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\\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?

Nov 28 '06 #1
5 2320
<Br*******@gmail.comschrieb:
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\\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/>

Nov 28 '06 #2
I've tried both ways.
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\Microsoft\Windows\CurrentVersion\Run")
doesn't work either.

On Nov 27, 9:01 pm, "Herfried K. Wagner [MVP]"
<hirf-spam-me-h...@gmx.atwrote:
<Brian8...@gmail.comschrieb:
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\\Microsoft\\Windows\\CurrentVersion\\Run")Rep lace "\\" with "\".

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 28 '06 #3

That OpenSubKey opens the key as read-only.

Try this:

My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\Microsoft\Windows\CurrentVersion\Run",
True )
Br*******@gmail.com wrote:
I've tried both ways.
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\Microsoft\Windows\CurrentVersion\Run")
doesn't work either.

On Nov 27, 9:01 pm, "Herfried K. Wagner [MVP]"
<hirf-spam-me-h...@gmx.atwrote:
<Brian8...@gmail.comschrieb:
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\\Microsoft\\Windows\\CurrentVersion\\Run")Rep lace "\\" with "\".
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 28 '06 #4
In addition, I think you should call DeleteSubKey rather than
DeleteValue to delete a key.

FishingScout wrote:
That OpenSubKey opens the key as read-only.

Try this:

My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\Microsoft\Windows\CurrentVersion\Run",
True )
Br*******@gmail.com wrote:
I've tried both ways.
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\Microsoft\Windows\CurrentVersion\Run")
doesn't work either.

On Nov 27, 9:01 pm, "Herfried K. Wagner [MVP]"
<hirf-spam-me-h...@gmx.atwrote:
<Brian8...@gmail.comschrieb:
>
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\\Microsoft\\Windows\\CurrentVersion\\Run")Rep lace "\\" with "\".
>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 28 '06 #5

Bingo! Thank you.

On Nov 27, 9:58 pm, "FishingScout" <fishingsc...@comcast.netwrote:
That OpenSubKey opens the key as read-only.

Try this:

My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\Microsoft\Windows\CurrentVersion\Run",
True )

Brian8...@gmail.com wrote:
I've tried both ways.
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\Microsoft\Windows\CurrentVersion\Run")
doesn't work either.
On Nov 27, 9:01 pm, "Herfried K. Wagner [MVP]"
<hirf-spam-me-h...@gmx.atwrote:
<Brian8...@gmail.comschrieb:
My.Computer.Registry.LocalMachine.OpenSubKey("SOFT WARE\\Microsoft\\Windows\\CurrentVersion\\Run")Rep lace "\\" with "\".
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3503
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
9
10858
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
6
1651
by: Alixx Skevington | last post by:
OK why does the following code work in a Windows form with a crystal report viewer but not in a webform. I get the usual CrystalReports.EngineLogONException logon Failed when this is called in...
0
372
by: sdb1031 | last post by:
Hi, I am trying to learn how to write, change and delete registry keys and values of a remote computer via Python's _winreg module. So far, I've been able to programmatically create a value and...
2
1777
by: Harry Barker | last post by:
Hi Group I Have to complete a small project and i need you guys help in doing it. I have to create a Tool that will automatically delete a file from the Harddrive and also deleting a SubKey from...
7
1820
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. I have an application that pulls files, folders and registry keys of installed programs. I'm wanting to with a context menu selection of "Delete...
1
5156
by: inika301 | last post by:
Mr Lebans. Could you help me ? We are trying to run your mdb to convert access reports to pdf but we can not, because an error happens. We are just using the A2000SnapShotToPDFver751 that is...
1
1193
by: ogo796 | last post by:
hi guys i have a problem here it seems like i dont get a solution.i manage to write to the text file but i want to update the existing line without writting a new line. my problem is when i want...
3
6327
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi all! I am having problems on installing .NET Framework 3.5 on some machines. In one machine the error is: '.NET Framework 3.5' RunCheck result: Install Needed Verifying file integrity of...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.