Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with SET DEFAULT TO 2

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
0
16
AU
In my app ( written 10+ years ago and now being revised and checked) I have a need to change the default folder on a number of occasions. I use SET DEFAULT TO (cNewfolder) and this works on every occasion except one which I am now trying to resolve. I need to be placed in a certain folder in this instance to make a backup of an ini file before changing the current ini in a certain way - allowing the current ini to be restored later.
I don't know if this is the problem but the path required is like
C:\Users\username\AppData\Roaming\the_target_ini_appnameI am unable to set my default to this folder to backup the ini file which resides there using COPY FILE (file1) to backupfile1.txt.
Can anyone advise me on this?

GenDev
Adelaide
South Australia
 
Chriss,
C> Anything else afterwards is just to teach you how things changed.
G> I have really enjoyed reading your explanations - when one is a lone operator it's hard to pick up all those points.

C> You simply have permissions on the files and folders, SET DEFAULT, copy and change the INI.
G> Having tried to do SET DEFAULT, copy and change the INI and failed - which was my first question to the forum -I'm not sure how to deal with the permissions issue. I can't see anything in the INNO help to explain that.

Regards
GenDev
 
Chriss,
This applies to the final exe obviously but how can I check/amend my code if I can't get to Roaming/TMG in the debugger. This where I came in..

GenDev
 
gendev said:
but how can I check/amend my code if I can't get to Roaming/TMG in the debugger.

After a setup makes sets the permissions you willbe able to SET DEFAULT TO where you permitted yourself to go.

And for already installed applications you still can apply an updated installer that sets the permissions. Or for the one off case of your own computer, use Windows Explorer and set permissions explicitly.

Chriss
 
Chriss,
This is the situation re permissions in Roaming/TMG for bryan on my dev PC before I make any changes to my INNO setup program.
TMG_roaming_mabi1l.png


I can't see how I can do better than that.
I have emended the exe line in INNO
Source: U:\Dev\_FoxPro\Dist_Folders\PathWiz_Dist\Programfull\pathwizv11.exe; DestDir: "{app}"; Flags: ignoreversion ; Permissions: everyone-full
I can't see how to nominate the roaming/TMG Dir though.
So running my pathwiz with test code again I see the same problem in the output.

newpw_iwznte.png

As can be seen (as before ) DO DEFAULT does not move to the TMG roaming folder but stays on pathwiz11 and the result of the file test is .F.
despite the dubugger moving to the 'Success' mesagge.
--------------
 
Regarding the Inno setup,k please click the links.

What is the name? Open your eyes. Within the [Dirs] section of an Inno Setup it is the name of a Directory. And in the [Files] section it is the name of a file.

Chriss
 
Reagardng SET DEFAULT:
Can you show the output of this (as a screenshot)?
Code:
? LEN(lcPath)
? LEN(ALLTRIM(lcPath))
? ">"+lcPath+"<"

Chriss
 
Chriss,

As previously noted in this thread the length of the path string is 54

path_oibxzv.png


C> Open your eyes.etc INNO says 'Creating subdirectories underneath the main application directory is a common use for this section.'
I know that but I am assuming it is the TMG roaming folder and that does not appear in my INNO file - it is accessed from within PathWiz. How can I add it to the INNO file then?

Inno uses
[Dirs]
Name: {app}
;Name: {app}\Docs
;Name: {app}\Reports
; Name: {userdocs}\Pathwiz Reports\HTML
Name: {userdocs}\Pathwiz Reports\WORD
Name: {userdocs}\Pathwiz Reports\CSV
Name: {userdocs}\Pathwiz Reports\LOG
is (userdocs) an appropriate place or is there another name I can use?

GenDev
 
gendev said:
How can I add it to the INNO file then?
You add it. If you add a path that already exists, you can still use the Permission: part to set the permission. It's straight forward.

Chriss
 
Aha, didn't you said you want to change into the TMG roaming folder?

According to your procmon output
TMGapp.ini_kbf9gh_uo67q1.png

That is C:\Users\bryan\AppData\Roaming\The Master Genealogist v9
And according to the output of my suggested test code:
path_oibxzv_mb9jma.png

That is C:\Users\bryan\AppData\Roaming\The Master Genealogist
Do you still not see the difference?
Are we talking about a wrong path for almost 2 weeks?

Chriss
 
Chriss,
As each user will have their own place in Users dir its not possible to anticipate what the problem path will be.
ie for me
C:\Users\bryan\AppData\Roaming\The Master Genealogist v9

GenDev
 
Again, open your eyes: The value in lcPath is missing the v9 part of the path.
What's really your problem? Eyesight, focus, short term memory?

The path in general will always be ADDBS(GETENV("APPDATA"))+"The Master Genealogist v9" in VFP code and within the INNO setup {userappdata}\The Master Genealogist v9

Well, and "always" depends on when whoever changes the folder name of the TMG application subfolder. TMG is not your software, so you don't decide that subfolder name. When it changes you have to adapt. No sytem directory function or environment variable will help you with that. When the developers of TMG decide their subfolder name should include a version number, that's the way it is. There's no function telling you the name of another applications appdata folder. So when you involve your application with the INI of another software and assume once finding out the appdata folder name is enough, then you don't have any idea of your own responsibiliities when you introduce a dependency of your software from how/where another software stores its files. It's usually non of your business, but if you make it your business you will have to stay up to date.

Chriss
 
Chriss,
Yes all of the above but I optimistically keep trying...

I am so sorry to have taken up your time with this - the V9 added to the path statement has allowed SET DEFA to work correctly.

As you say, way back TMG added the version number to the exe and my hard coded app name missed it. and I wasn't alert enough to spot that. A red faced Mea Culpa
I have learned a lot from your posting and I thank you for that.
Now to test the rest of the code - BUT the copy of the ini has worked though.

GenDev
 
One question that remains is why you didn't get an error. My guess is that both the old and new appdata folder of TMG exist. So your code also did copy and modify the old ini, just TMG9 did not read it from there.

The general problem of knowing the appdata (sub) folder of a third party application you don't have control over is not solvable, but do you install TMG alongside your application? Then you know the version you install alongside and where its ini is. What could be helpful to make this an ini setting of your ini so users can adapt this. And you could check the exe name and size of the TMGx.EXE, and note down where the ini is for each versio of TMG to have that knowledge available at least about all versions you know.

Chriss
 
Chriss,

Overwhelmingly the TMG community worldwide have been encouraged to use the last version released in 2014 - that's Ver 9.04. Production of the software has finished with the author pulling the plug and taking up other pursuits. Genealogists who use TMG believe it to be the best s/w for Family History. My app only works as an add-on to TMG. Thus my app will be unlikely to be used in conjunction with any other version. If it is my code will (now) recognise any older versions and find the ini files location without any dramas.

Regards
GenDev
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top