Hi,
I tried to create an app that creates an ".ini" file in the application folder (Final Install Folder: Program Files) but there was an error when the application tried to create a file.
I used this installer maker:
The ".ini" file is created with this library:
The standalone application is created with this function:
Error observed in debug mode when app tried to create ".ini" file:
This error did not occur when the app was run as an administrator.
But after the ".ini" file was created, it no longer needed to run the app as an administrator.
So I tried to make an installer that already left the ".ini" file created in the app folder, and it worked, it was not necessary to run the app as an admin.
Including the ".ini" file in the installer seems like an easy way to solve this problem, but it might be interesting to know how to get permission to write to this Program Files folder.
I found this but didn't test it:
Problem description:
Possible solution:
Source: https://stackoverflow.com/questions/21052384/write-to-c-program-files-from-java-program
I tried to create an app that creates an ".ini" file in the application folder (Final Install Folder: Program Files) but there was an error when the application tried to create a file.
I used this installer maker:
The ".ini" file is created with this library:
[B4X] KVS2 / KeyValueStore 2 - Simple & Powerful Local Datastore
Recommended to use the newer b4xlib: https://www.b4x.com/android/forum/threads/b4x-kvs2-keyvaluestore2-library.120234/
www.b4x.com
The standalone application is created with this function:
Integrated B4JPackager11 - The simple way to distribute standalone UI apps
B4JPackager11 is a utility written in B4J that uses the underlying Java tools to create a standalone package that doesn't depend on any other software being installed. It works with OpenJDK 11 and OpenJDK 14. Starting from B4J v8.30 it is integrated in the IDE and available under Project - Build...
www.b4x.com
Error observed in debug mode when app tried to create ".ini" file:
C:\Program Files (x86)\MyApp\bin>java.exe @release_java_modules.txt -m b4j/b4j.example.main
(SQLException) java.sql.SQLException: opening db: 'C:/Program Files (x86)/MyApp/Init.ini': Access denied
This error did not occur when the app was run as an administrator.
But after the ".ini" file was created, it no longer needed to run the app as an administrator.
So I tried to make an installer that already left the ".ini" file created in the app folder, and it worked, it was not necessary to run the app as an admin.
Including the ".ini" file in the installer seems like an easy way to solve this problem, but it might be interesting to know how to get permission to write to this Program Files folder.
I found this but didn't test it:
Problem description:
I have written a Java application that includes a self updater. The self updater loads new program versions from a web server and replaces the application files. While this works perfectly if the application is installed e.g. in the users home directory, it fails on windows machines if it's installed in the C:\Program Files folder. This is because the JVM is executed under the user’s account which has no write access to the program directory. If a native program, e.g. an installer, tries to write to the program folder, usually a popup appears asking the user to permit the write operation. This doesn’t happen for java applications. Why?
Possible solution:
If you are using inno setup compiler to generate your launcher, then you can change your app directory permission.
For example, if you need full control and want to update files under AppName/data folder
[Dirs]
Name: "{app}";
Name: "{app}\data"; Permissions: everyone-full
[Files]
Source: data\*; DestDir: {app}\data\; Flags: ignoreversion recursesubdirs createallsubdirs; Permissions: everyone-full
Source: https://stackoverflow.com/questions/21052384/write-to-c-program-files-from-java-program