|
-
Oct 12th, 2011, 07:28 AM
#1
Thread Starter
Junior Member
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?
-
Oct 12th, 2011, 09:48 AM
#2
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.
-
Oct 12th, 2011, 03:36 PM
#3
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 12th, 2011, 03:55 PM
#4
Lively Member
Re: Vb. Error accessing the system registry
 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
-
Oct 12th, 2011, 04:19 PM
#5
Thread Starter
Junior Member
Re: Vb. Error accessing the system registry
 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?
-
Oct 12th, 2011, 04:21 PM
#6
Lively Member
Re: Vb. Error accessing the system registry
 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
-
Oct 12th, 2011, 04:24 PM
#7
Thread Starter
Junior Member
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.)
-
Oct 12th, 2011, 04:32 PM
#8
Lively Member
Re: Vb. Error accessing the system registry
 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!
-
Oct 13th, 2011, 01:24 PM
#9
Thread Starter
Junior Member
Re: Vb. Error accessing the system registry
 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!
-
Oct 13th, 2011, 02:16 PM
#10
Lively Member
Re: Vb. Error accessing the system registry
 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.
-
Oct 14th, 2011, 01:33 AM
#11
Thread Starter
Junior Member
Re: Vb. Error accessing the system registry
What is the difference if in manifest file instead of, level="requireAdministrator" I put, level="asInvoker" ?
-
Oct 14th, 2011, 08:48 AM
#12
Lively Member
Re: Vb. Error accessing the system registry
 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.
-
Oct 16th, 2011, 06:27 AM
#13
Thread Starter
Junior Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|