Java:System. Getenv (“appdata”) returns null. What is it now?

I just found that when a java program is started on windows as another user through "run as..." (from the context menu of the executable file), the system The call to getenv ("appdata") will return null instead of the usual application data folder

Now, when it comes to windows folders, I'm a bit like a rookie, so my question is, how should I deal with this situation when my program must be able to store data somewhere in order to work normally? More specifically, if system Getenv ("appdata") returns null. I can even allow any data to be stored. If so, where? Thank you in advance!

Solution

OK, I solved my problem with JNA:

com.sun.jna.platform.win32.Shell32Util.getFolderPath(int nFolder)

Where nfolder = 0x001a represents the application data folder, and nfolder = 0x001c represents the local application data folder On Windows XP, the output is

Most importantly, this does not return null when the program is started through run as

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>