changing registry on vista
ok i am trying to set up a program that will edit services via the registry. when i try to run the program it get this error: Access to the registry key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TrkWks' is denied.
when i build it and try to run i get :
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.UnauthorizedAccessException: Access to the registry key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TrkWks' is denied.
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistrySecurity registrySecurity)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey)
at Microsoft.Win32.Registry.SetValue(String keyName, String valueName, Object value, RegistryValueKind valueKind)
at Microsoft.VisualBasic.MyServices.RegistryProxy.SetValue(String keyName, String valueName, Object value)
at Registry_sets.Form1.cmdStart_Click(Object sender, EventArgs e) in J:\registry sets\Registry sets\Registry sets\Form1.vb:line 4
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Registry sets
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/registry%20sets/Registry%20sets/Registry%20sets/bin/Release/Registry%20sets.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
can any explain how i can fix this i tried adjusting the uac and adjust the app.manifest that vb08 opened and adjusted the code to this;
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</asmv1:assembly>
Re: changing registry on vista
Obviously you are not authorized to do such. Are you running this program under administrative privileges?
Re: changing registry on vista
right click on your app, and select run as administrator, and it should work. Vista does not allow non elevated processes to write to HKLM
Re: changing registry on vista
i tried that last night and i got the same error again
Re: changing registry on vista
Quote:
Originally Posted by kleinma
Vista does not allow non elevated processes to write to HKLM
Why Does Not allow To Write in Registry ?
What do You mean by elevated processes ?
Re: changing registry on vista
Quote:
Originally Posted by killer7k
Why Does Not allow To Write in Registry ?
What do You mean by elevated processes ?
Its a security feature.
Letting applications that arent being runned as admin write to the registry as it pleases is a security risk.
Re: changing registry on vista
killer, if you are not familiar with using Vista, it uses pretty much a totally different security model.
Basically the only totally unlocked account on the system is the built in administrator account. All other accounts, even if they are members of the administrators permissions group, only run as a standard windows user.
The difference between a user in the administrators group, and a user that is not in the administrators group, is that when an administrative task needs to be done (like launching certain programs or changing certain settings in Windows) windows simply prompts you for your permission to perform the action if you are a member of administrators. If you are not, you can put in a user id/password of someone with admin rights to perform the task.
Another thing is file and registry virtualization. What Vista does to help with backward compatibility (for example the app is install in the program files directory and writes to files in its own directory, program files is considered read only in vista unless you are an administrator) What it actually does is creates a virtual location under the given users profile but makes the app think its really a directory in program files so it wont fail when trying to write a file. This also exists in the registry for keys that normally you would have been able to write to in XP and prior, but now you can not in Vista.
It can be a bit confusing if you dont know about it, because it can give undesired results sometimes in applications.
Re: changing registry on vista
Yes Totally Agree
I was Thinking when you said Dont allow Write in Registry that is for Admin Also
I never used Vista Still like my XP !
Re: changing registry on vista
Quote:
Originally Posted by Atheist
Its a security feature.
Letting applications that arent being runned as admin write to the registry as it pleases is a security risk.
Yes misunderstood , i was thinking for admin also
Re: changing registry on vista
ok so how do i fix my problem. sorry my flash drive went on me with my program on it and i have to do it from scratch but but how do i use the registry set with that key i used
Re: changing registry on vista
Why do you need to modify services via the registry? You will probably not get the feffects you desire becuase you may have to refresh the services by stopping and restarting them. Why not just use a service controller component?
Re: changing registry on vista
its for my job. one of the functions we have is when we sell a new computer with our start up services we cut out unnecessary services from starting so by the time the customer get the computer it has already been restarted.
Re: changing registry on vista
If you create images of the configurations of Windows installs, you can set all those things before its imaged. Then upon a new system purchase you load the image of windows configured as needed and your done. This is how it is done by system manufacturers.
Re: changing registry on vista
sadly i don't not know to do that nor would be allowed to do that. i work at best buy / circuit city and i work with a wide range of manufactures so i could not create an image and use it i would have to create to many to count and i think there would be problem with product keys. i just need a way to set this program to run at admin lvl so there are no problems with the uac
Re: changing registry on vista
how do you work at best buy / circuit city? Aren't the 2 competing stores?
Are you trying to create a program that you personally have to run once to disable certain services before you sell the computer to a customer? Or are you trying to create a program that always runs when the customer turns on the computer?
Re: changing registry on vista
Quote:
Originally Posted by kleinma
Basically the only totally unlocked account on the system is the built in administrator account. All other accounts, even if they are members of the administrators permissions group, only run as a standard windows user.
Erm, that's not entirely accurate. By default most users are still Adminsitrators and the "root" Adminsitrator still has to request elevation for Admin things.
Re: changing registry on vista
What actions in Vista require an elevation prompt when you are logged in as "administrator" on the local machine?
Re: changing registry on vista
Quote:
Originally Posted by kleinma
What actions in Vista require an elevation prompt when you are logged in as "administrator" on the local machine?
All usual items as far as I know (I have no way to currently test this and it's been a while since I last logged in as Administrator). The idea of UAC wasn't to prevent people who didn't have the privledge to do something but to let the user know that someone wants to do something that requires a higher level of authorization (whether that "someone" is the user or not).
If they didn't use UAC in an administrator account... well that would basically undo everything they tried to do with UAC in the first place.
Re: changing registry on vista
well I really don't know what to tell you then.
I am sitting at a Vista machine right now, and if I login as an account which is a member of the administrators group, and I (for example) go to start -> run -> regedit.exe
I get an elevation prompt
If I do the same thing under the administrator account, I do not. The process starts right up with no prompts at all. Infact the run dialog even tells you that any process you start from there will be run with elevated admin rights when logged on as "administrator"
Also just to make sure this was not a "feature" of the run dialog, I did the same thing by going to c:\windows and double clicking regedit.exe from there. Same result.