CommonAppData on Windows 10 systems

Discuss any general programming issues here
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

CommonAppData on Windows 10 systems

Post by amyren »

Using GetSystemInfo and using CommonAppData to get the path will result in <sysdrive>\ProgramData

This works fine on windows 7 systems, but it seems this is changed since windows 10. If you put files in <sysdrive>\ProgramData they will only be available for writing for the user that have installed it or users with admin rights.
Googling this issue it looks like the \ProgramData folder is ment for static appdata files in Windows 10. Changable files should be put in <sysdrive>\Users\Public\AppData\

As far as I know Hollywood cant tell whitch WIndows version its running on, so as a workaround I must make a separate executable to use on WIndows 10 systems. And set it to use <systemdrive>\Users\Public\AppData\ instead of <CommonAppData>
I try GetEnv("os") to determine the windows version, but returns Windows_NT on both Win7 and 10.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: CommonAppData on Windows 10 systems

Post by airsoftsoftwair »

I think what you're looking for is "AppData", not "CommonAppData", i.e.

Code: Select all

p$ = GetSystemInfo().AppData
This will return a location you can write to.
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: CommonAppData on Windows 10 systems

Post by amyren »

"AppData" points to C:\Users\UserName\AppData\Roaming, and I can read/write to files put here. But other users will not have access to this folder.

Writable common application data is in C:\Users\Public\AppData\ on windows 10 systems, but there seems not to be a pointer to it.
If I could find a method to tell me whether the program is running on Windows 10 or newer, I could have a way to work abound this. Now my workaround is to create a separate executable for use on Windows 10 systems.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: CommonAppData on Windows 10 systems

Post by airsoftsoftwair »

amyren wrote: Sun Dec 27, 2020 10:58 am Writable common application data is in C:\Users\Public\AppData\ on windows 10 systems
Says who? I don't even have an "AppData" folder in C:\Users\Public on my Windows 10 system.

"CommonAppData" from GetSystemInfo() returns C:\ProgramData on both my Windows 7 and my Windows 10 system. There is no difference. This is the folder Microsoft recommends for, well, common app data :) Hollywood just returns the value of CSIDL_COMMON_APPDATA.

But I think there are quite some design issues about this folder because other people are confused as well, see here: https://stackoverflow.com/questions/221 ... rogramdata

However, I haven't seen any official reference to C:\Users\Public\AppData as a folder for appdata for all users... if you have one, let me know... so as it stands, C:\ProgramData seems to be the only folder for application data for all users...
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: CommonAppData on Windows 10 systems

Post by amyren »

It seemes to be an issue for many win 10 users.

https://answers.microsoft.com/en-us/win ... 64647176af

116 people have answered that they have the same question. Only a few people is happy with the proposed solution. OP replies, and I find his reply very much describes the same experience I have. Sadly the thread is closed without further replies.

On the company Windows 10 pc's I checked, the C:\Users\Public\AppData folder was present, and there was even a \Local\MicroSoft\Windows entry in there already. However, I see that it is not present on another private Pc with a recent win10 installation.
But that doesent change so much on my part, I just use C:\Users\Public and let my program create the needed folders in there, and it will work for all users.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: CommonAppData on Windows 10 systems

Post by airsoftsoftwair »

Yeah, I'm afraid that this is a Windows issue, not a Hollywood one. So you need to find some way to work around it :(
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: CommonAppData on Windows 10 systems

Post by amyren »

Is there a way for Hollywood to detect whitch Windows version it is running on?
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: CommonAppData on Windows 10 systems

Post by plouf »

Code: Select all

DebugPrint(ReadRegistryKey(#HKEY_LOCAL_MACHINE,
      "Software/Microsoft/Windows NT/CurrentVersion/CurrentVersion"))

; 5.0		Win2000
; 5.1		Win XP
; 5.2		Win XP 64bit/2003 server
; 6.0		Vista / 2008 Server
; 6.1		Win 7 / 2008 Server
; 6.2		Win 8 / 2012 Server
; 6.3		Win 8.1 / 2012 Server
; 10.0		Win 10
However you are aprroching your problem wrong, as Andreas said as long as the OS suggest a specific path for "common data" you should use the suggested method, for current AND future compatibility

think of what happened in pas with "C:\" its my hard disk ;-)
Christos
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: CommonAppData on Windows 10 systems

Post by amyren »

plouf wrote: Sun Jan 03, 2021 5:48 pm

Code: Select all

DebugPrint(ReadRegistryKey(#HKEY_LOCAL_MACHINE,
      "Software/Microsoft/Windows NT/CurrentVersion/CurrentVersion"))

; 5.0		Win2000
; 5.1		Win XP
; 5.2		Win XP 64bit/2003 server
; 6.0		Vista / 2008 Server
; 6.1		Win 7 / 2008 Server
; 6.2		Win 8 / 2012 Server
; 6.3		Win 8.1 / 2012 Server
; 10.0		Win 10
However you are aprroching your problem wrong, as Andreas said as long as the OS suggest a specific path for "common data" you should use the suggested method, for current AND future compatibility

think of what happened in pas with "C:\" its my hard disk ;-)
Thanks for the info about the ReadRegistryKey command. Although on my Windows 10 Home laptop the currentversion will report 6.3 and not 10.0

As stated earlier the data I put inside "CommonAppData" ended up as not writable for anyone but the current user, and "AppData" is the appdata for the current user and not ideal when I want the program data to be available for other users on the same computer.
So my approach may be wrong, but at least it is working for me.
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: CommonAppData on Windows 10 systems

Post by plouf »

using google search, found the following conversation

https://stackoverflow.com/questions/310 ... m-registry

explains why if you get "6.3" you should double check using the new variables
CurrentMajorVersionNumber and
CurrentMinorVersionNumber

if it works for you, please post result for future help, since i have not handy win10 atm to check
Christos
Post Reply