2 Attachment(s)
VB6 - ProgData.Path to fix the App.Path problem
Lots of people are still struggling with old VB6 programs that run afoul of App Compat file virtualization in current versions of Windows.
It looks like these programs need a quicker fix than a thorough review and rewrite. Here's another idea to help do this.
ProgData.Path
First, we add a Class called ProgData with a Property named Path. Then we change any path-building logic in the program that uses App.Path to use ProgData.Path instead.
What ProgData.Path returns is a new path within CommonAppData (ProgramData) named the same as the installed application's path within Program Files (Programs).
For:
C:\Program Files\FuddCo\FuddApp
We get back the folder expanded from:
{CSIDL_COMMON_APPDATA}\FuddCo\FuddApp
ProgDFix.exe
To make this work, we need to relocate the writeable files from Program Files to the new ProgData.Path folder after creating it and setting security to allow all-user read/write/delete access.
ProgDFix.exe can do this for you. Just run it once after installation and it will move those files and deal with the security settings for you. Note that to accomplish this ProgDFix.exe runs elevated, which is why you'd want to do it as a last step in your install if possible.
Attachment
The attached archive has all of the necessary code and some example files to play with. This is described in the included ProgData.rtf document.
I hope it helps somebody.
Re: VB6 - ProgData.Path to fix the App.Path problem
There is an error in ProgDFix.
App.path "Dummy" does not exist.
Code:
Err.Raise &H8004B100, TypeName(Me), "AppPath """ & RHS & """ doesn't exist"
Re: VB6 - ProgData.Path to fix the App.Path problem
I can't find any errors. I just tried it again and it works fine. If you read the ProgData.rtf guidance document, under Testing ProgDFix.exe the very first step is:
- Copy the included folder Dummy under Program Files/Programs manually. This will be a simulated installed program, but without any EXE (just some folders and files).
That puts the folder in place for testing.
As the third step there says:
- Note that the Project has a command line set up already for Dummy and some files and folders under that folder:
Msg|Dummy|EmptyFolder|FolderToGetMoved|FileToGetMoved.txt
So to test with a different installed program (or simulation folder) provide appropriate command line parameters.
If you clear the command line in the IDE (Project|ProgDFix Properties... Make tab) the program will just terminate with "nothing to do."
Re: VB6 - ProgData.Path to fix the App.Path problem
Note:
The example DummyApp PDW setup was tested on Vista SP2, Win7 RC, and XP SP3. No issues. Should also work fine with Win2K SP 2 or later. Should even work for Win9x (including Win95 with the Desktop Update).
I need to build a Win7 SP1 VM yet but I expect no problems.