Vb. Error accessing the system registry
I have a program of mine writen in VB4. It is a simple calendar program and works fine all these years. But when it is installed (from its setup file) in a computer with windows vista or 7, then the first time that the user tries to run it, he receives the message: "Error accessing the system registry" and then: "Unexpected error; quitting". I know the solution. Right click and select "Run as administrator". But some computer users do not know that (to select the first time this selection - Run as administrator).
So my question has 2 brunches.
1. Is it possible to add something in the program's code to inform or warn the user, just before or just after these messages above, (and before the program closes), as a promptness or instruction, to select the next time "Run as administrator"? (like a msg box for example).
2. Or anything else in the program's source code or in setup building to bypass this problem?
Re: Vb. Error accessing the system registry
Programs should not normally do this. The installer should run "as administrator" (this is called "elevated" these days) and take care of registering components and creating folders and setting permissions on them.
But the question is, can your program detect these errors and handle them?
If so, the program could just rerun itself elevated and terminate.
Re: Vb. Error accessing the system registry
i read this differently to dilettante, looks like your instal works correctly but the program fails when run
if you add a manifest to /for your program, it can prompt for admin password
search in this and codebank forums for manifest files
la volpe has posted a project, in codebank, to add /create manifests to put into resource file
there is also a method /program available, to add a manifest directly to a compiled exe
Re: Vb. Error accessing the system registry
Quote:
Originally Posted by
giann
I have a program of mine writen in VB4. It is a simple calendar program and works fine all these years. But when it is installed (from its setup file) in a computer with windows vista or 7, then the first time that the user tries to run it, he receives the message: "Error accessing the system registry" and then: "Unexpected error; quitting". I know the solution. Right click and select "Run as administrator". But some computer users do not know that (to select the first time this selection - Run as administrator).
So my question has 2 brunches.
1. Is it possible to add something in the program's code to inform or warn the user, just before or just after these messages above, (and before the program closes), as a promptness or instruction, to select the next time "Run as administrator"? (like a msg box for example).
2. Or anything else in the program's source code or in setup building to bypass this problem?
You could include a manifest file with your executable (this tells Windows to run the program as administrator automatically.)
OR
You can embed the manifest file inside the EXE directly with Resource Hacker.
It was really grinding away at me until I figured this one out... I was so happy I had to blog about it. Here is my blog with instructions and a sample manifest file: http://blog.foolishit.com/2011/01/vb...embedding.html
Re: Vb. Error accessing the system registry
Quote:
Originally Posted by
Foolish Tech
You can embed the manifest file inside the EXE directly with Resource Hacker.
What is a manifest file and how could I embed it inside the exe?
Re: Vb. Error accessing the system registry
Quote:
Originally Posted by
giann
What is a manifest file and how could I embed it inside the exe?
ahem... see the link to my blog :P
Re: Vb. Error accessing the system registry
Or how can I create this manifest file and how can I include it with my executable? (to tell Windows to run the program as administrator automatically.)
Re: Vb. Error accessing the system registry
Quote:
Originally Posted by
giann
Or how can I create this manifest file and how can I include it with my executable? (to tell Windows to run the program as administrator automatically.)
IF YOU CLICK THE LINK I POSTED TO MY BLOG....
it will answer all your questions. Just use the sample manifest file I provided for download, and follow the instructions!
Re: Vb. Error accessing the system registry
Quote:
Originally Posted by
Foolish Tech
IF YOU CLICK THE LINK I POSTED TO MY BLOG....
it will answer all your questions. Just use the sample manifest file I provided for download, and follow the instructions!
Thank you!
Re: Vb. Error accessing the system registry
Quote:
Originally Posted by
giann
Thank you!
Your welcome, glad you got it sorted. This is the first time I've actually had something to *contribute* to these forums rather than coming here with my own problems. :)
Re: Vb. Error accessing the system registry
What is the difference if in manifest file instead of, level="requireAdministrator" I put, level="asInvoker" ?
Re: Vb. Error accessing the system registry
Quote:
Originally Posted by
giann
What is the difference if in manifest file instead of, level="requireAdministrator" I put, level="asInvoker" ?
source: HERE
asInvoker
The application runs with the same access token as the parent process.
Recommended for standard user applications. Do refractoring with internal elevation points, as per the guidance provided earlier in this document.
highestAvailable
The application runs with the highest privileges the current user can obtain.
Recommended for mixed-mode applications. Plan to refractor the application in a future release.
requireAdministrator
The application runs only for administrators and requires that the application be launched with the full access token of an administrator.
Recommended for administrator only applications. Internal elevation points are not needed. The application is already running elevated.
Re: Vb. Error accessing the system registry
Everything is ok! I created a manifest file with level="asInvoker" and I embed this file inside the EXE with Resource Hacker.
Thank you all!