473,473 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

registry permissions

I am trying to write a program to switch off serial port enumerations
via the associated registry key. My code is:

RegistryPermission permission = new
RegistryPermission(RegistryPermissionAccess.Write,
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\En um\\ACPI\\PNP0501");
permission.Demand();
RegistryKey key =
Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentC ontrolSet\\Enum\\ACPI\\PNP0501",
true);
But the last line throws a Security Exception saying "Requested
security access is not allowed". What am I doing wrong?

Colin
Jun 3 '07 #1
4 3264

"Colin Priest" <co**********@no.spam.comwrote in message
news:d2********************************@4ax.com...
>I am trying to write a program to switch off serial port enumerations
via the associated registry key. My code is:

RegistryPermission permission = new
RegistryPermission(RegistryPermissionAccess.Write,
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\En um\\ACPI\\PNP0501");
permission.Demand();
RegistryKey key =
Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentC ontrolSet\\Enum\\ACPI\\PNP0501",
true);
But the last line throws a Security Exception saying "Requested
security access is not allowed". What am I doing wrong?
Does the user account that this program is running under have the
permissions to change the registry node?

Jun 3 '07 #2
Colin,

There are two things I can think of. First, the user account you are
running this under doesn't have the appropriate rights to access the
registry key. The second is that you are running the application from a
network share, or from the internet, and as a result, .NET is sandboxing the
application so that it doesn't do any harm.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Colin Priest" <co**********@no.spam.comwrote in message
news:d2********************************@4ax.com...
>I am trying to write a program to switch off serial port enumerations
via the associated registry key. My code is:

RegistryPermission permission = new
RegistryPermission(RegistryPermissionAccess.Write,
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\En um\\ACPI\\PNP0501");
permission.Demand();
RegistryKey key =
Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentC ontrolSet\\Enum\\ACPI\\PNP0501",
true);
But the last line throws a Security Exception saying "Requested
security access is not allowed". What am I doing wrong?

Colin
Jun 3 '07 #3
"Colin Priest" <co**********@no.spam.comwrote in message
news:d2********************************@4ax.com...
>I am trying to write a program to switch off serial port enumerations
via the associated registry key. My code is:

RegistryPermission permission = new
RegistryPermission(RegistryPermissionAccess.Write,
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\En um\\ACPI\\PNP0501");
permission.Demand();
RegistryKey key =
Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentC ontrolSet\\Enum\\ACPI\\PNP0501",
true);
But the last line throws a Security Exception saying "Requested
security access is not allowed". What am I doing wrong?

Colin


You don't have the right to open this key for write access, regular users,
including administrators, can only open this key for reading. This whole
registry tree is owned by the OS device manager, what exactly are you trying
to achieve?

Willy.

Jun 3 '07 #4
On Sun, 3 Jun 2007 19:32:38 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.bewrote:
>"Colin Priest" <co**********@no.spam.comwrote in message
news:d2********************************@4ax.com.. .
>>I am trying to write a program to switch off serial port enumerations
via the associated registry key. My code is:

RegistryPermission permission = new
RegistryPermission(RegistryPermissionAccess.Write ,
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\E num\\ACPI\\PNP0501");
permission.Demand();
RegistryKey key =
Registry.LocalMachine.OpenSubKey("SYSTEM\\Current ControlSet\\Enum\\ACPI\\PNP0501",
true);
But the last line throws a Security Exception saying "Requested
security access is not allowed". What am I doing wrong?

Colin

You don't have the right to open this key for write access, regular users,
including administrators, can only open this key for reading. This whole
registry tree is owned by the OS device manager, what exactly are you trying
to achieve?

Willy.

Thank Willy. As I said above, I am trying to set the registry keys to
stop enumeration of serial devices. I need to do this to stop Windows
incorrectly recognising my serial device as a mouse etc.

The user account full administrator access. What else do I need?

Jun 4 '07 #5

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

Similar topics

0
by: DJP | last post by:
Hi there I need to be able to programmatically set permissions on registry keys using VB / VBScript / VBA. So far I have had a look at doing this using the WScript.Shell object, API calls, and...
1
by: Daniel Passwater via DotNetMonster.com | last post by:
I'm working on a app that displays according to a registry key value. The user needs the ability to update the display, and hense the registry key (via a click event on a popup menu). This all...
21
by: Kevin Swanson | last post by:
I'm attempting some remote registry manipulation via C#. I've written a test app to simply grab a specified key from a specified hive on a specified machine. The call to OpenSubKey is throwing...
3
by: Dmitriy Kolesnik | last post by:
Hello all! I have problem with reading data from registry. I work on the one machine. My operation system is Windows XP SP2. I read data from registry with help OpenSubKey and SecurityException...
1
by: Kevin Burton | last post by:
I am using aspnet_setreg but the permissions that it sets the registry to leave the application unable to access the information. I want to add the ASPNET account on the machine that our...
8
by: Al Kaufman | last post by:
I have a simple console app that uses: regSubKey = <some registry key> Dim reg As RegistryKey = Registry.ClassesRoot.OpenSubKey(regSubKey) Dim path As String path = CStr(reg.GetValue(""))
4
by: Kevin L | last post by:
I store some application settings in the registry under HKEY_LOCAL_MACHINE\Software\MyApplication I want to allow full access to this key and subkeys. Currently, I manually change the...
1
by: PiotrKolodziej | last post by:
Hi Here is the code: this.regPath = @"Software\FileManager\" ; System.Security.Permissions.RegistryPermission permissions = new...
3
by: Sreppohcdoow | last post by:
I have a simple tool that I create that stores some settings in the Registry... however, if the user running it doesn't have Admin priveleges on the machine, the app fails when trying to write to...
0
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain,...
0
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
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
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
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...

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.