Unable to write to registery with Vista even as admin
My program that works fine in XP now does not write anything to the registry in Vista. I created an admin user on vista and even with that user, it still will not do this.
For example, my program lets you add or remove it from windows startup at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
My install program that can run as administrator puts it there but my own VB app will not put it there again if I delete it manually. And I am loggin in as an admin user. Why would this be happenning?
Thanks
Warren
Re: Unable to write to registery with Vista even as admin
Vista has a lot of security advantages, i guess we can call them that. If your not a administrator account it could be it is writing to a different key. I believe it writes to a different key silently. Check if there are any new keys HKEY_####, have a read of the below link to:
Modifications Required for VB6 Applications to work on VB6
Re: Unable to write to registery with Vista even as admin
No, you shouldnt be writting to the registry anymore. Vista uses a process called Registry Virtualization which is why you are not finding your writes.
You can not write to HKLM anymore. Also, Microsoft is only providing the virtualization workaround on a temporary basic. It will be discontinued so you shouldnt use the workaround or rely upon it.
Re: Unable to write to registery with Vista even as admin
How owuld you add your program to startup if you cannot write to the registry anymore?
And if I should not be using the registry anymore, do we have to go back to ini files then?
Thanks
Re: Unable to write to registery with Vista even as admin
Also, other software can still write to the registry such as my installer I use. It can write anywhere in the registry including in the Run area. So why would another program be able to write to the registry but VB6 apps cannot?
Warren
Re: Unable to write to registery with Vista even as admin
Use the CurrentUser hive:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
Re: Unable to write to registery with Vista even as admin
I want it to run for all users that login though.
Re: Unable to write to registery with Vista even as admin
Quote:
Originally Posted by WarrenW
I want it to run for all users that login though.
Unless one of them disables it, at which point it no longer runs at startup for anybody? Is that really the functionality you want?
Re: Unable to write to registery with Vista even as admin
You could handle it this way:
Installer adds key to LocalMachine\Run, but includes a command line parameter to indicate it's an autorun on startup. When program launches, before doing or displaying anything, it first checks the command line parameter to see if it's been autorun. If so, it checks a registry key under CurrentUser\Software\Company\App to see if this user wants to run on startup. If the key isn't there, create the key defaulting to yes and load normally. If the key is there and says no, exit gracefully without showing the user anything.
That way it will run on startup for everyone after install until they disable it, at which point it is only disabled for that user.
I'm not saying this is a particularly good way to go, but it would work.
Re: Unable to write to registery with Vista even as admin
I'm just puzzled why I cannot write to the registry when other software can. I use the Install Creator Pro by clickteam.com and they have a checkbox to make it run as an administrator so it can do this stuff. Why can't we do this in VB6? Is there something special they can do in C++ or other language that is not supported in VB6?
Thanks
Re: Unable to write to registery with Vista even as admin
How are you writting to the registry? Using the APIs?
Re: Unable to write to registery with Vista even as admin
Yes, I use APIs for read and write on the registry. I tested out writing to the HKCU and I can do that as you said. I was wanting to use HKLM so all users will have the same settings which I need.
I'll keep tinkering with it all!
Thanks