I am creating an application in electron and I need to obtain the path to the script files of the same application (regardless of the operating system) to modify these scripts and do file preloading actions, the path in which the scripts are generated is as follows:
C:\Users\Emartinezb\Desktop\electron-win32-x64\resources\app
However that path will always vary since the user can put the folder where the electron EXE is located anywhere they want, so I need to find the path to get to resources\app regardless of the operating system and regardless of where the user is. located the electron folder (electron-win32-x64 this is the root folder where the exe is)
Any help on this please?
Related
How to change the MSIX installation path??
Referred this url - "https://learn.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes"
Always installer package is created in default location "C:\Program Files\WindowsApps"
Need to set the installer location to different location.
The installation path of an MSIX package cannot be changed. All the files you have included in your package are installed inside an app-specific folder under "C:\Program Files\WindowsApps<your app>\".
This is a design decision from Microsoft. Only for MSI/EXE installers you can change the install path.
If you want to add files in other folders too, you need to copy them the first time your application is launched. For that, you have multiple options. You can write your own code inside your application to copy the files in other folders or you can use tools like Advanced Installer to do it for you.
To understand more about MSIX and how files outside of the installation path can be managed I recommend this article/presentation I wrote last month.
Background, I currently use Izpack for my Windows installer, I bundle a java runtime and use winrun4j as a wrapper both for the installation and the actual program once installed. It worked for a long time but there are a number of problems with the installer that I have not been able to solve and have been looking to replace it.
Oracle now provide the JPackage installer so it seems like a sensible choice. But the folder structure created by the installer is different to what I currently have, I have a number of config and non java files and I have not been able to get the .exe that JPackage creates to do anything.
So is it possible to use JPackage to create the installer but in a strcuture better matching my existing structure, and use continue to use WInRun4j to actyally run my application
Existing Folder Structure
ROOT
---App.exe
---Config Files
---lib
-------jar files
---JVM64
------- Java runtime
---help
JPackage structure
ROOT
---App.exe
---Runtime Dlls
---app
----- jar files
Config files
--runtime
------Java runtime
------Runtime Dlls (again)
The structure of directories generated by jpackage is mainly set up for you and does not seem possible to change, and makes installation of Java app dependencies very easy with self contained JRE. The basic structure for Windows is as you say:
ROOT
---App.exe (for --main-class parameter)
---xyz.exe (for each --add-launcher parameter)
---Runtime Dlls (these appear to be unused except for applauncher.dll, see SO 62607300)
---app/
------App.cfg (for --main-class)
------xyz.cfg (for per --add-launcher)
---runtime/
------Java runtime
------Runtime Dlls
With --input and --main-jar params you are free to setup additional directory structure under app/ folder for anything else you want for your application. So if you used lib/myappjar.jar it would add:
---app/
-------lib/
----------myappjar.jar
If you used --input build\mypath it would copy the entire tree of files under that folder, so if build\mypath dir contained
bin/
---Scripts
---xyz.properties
README.txt
Then app would also contain:
---app/
------bin/
---------Scripts
---------xyz.properties
------README.txt
By the way the Runtime DLLs placed at top level appear to be copies of some of the DLLs under runtime/bin
[https://stackoverflow.com/questions/62607300/why-is-java-jpackage-installing-windows-dll-files-in-two-places]
I'm creating a portable Electron app that writes some files to the program folder. It works pretty well when I package it without the --asar option in Electron-packager, which leaves the resources folder with plain html + js files.
Now when I try to compile it with the --asar option, so that it packages the resources folder into one file, I can't access the program directory any more with the following code:
remote.app.getAppPath()
This now returns the path of the asar file, so I can't really write to the application folder any more. Is there any way around this?
No, you cannot modify the asar of a running Electron app. You should be saving your config outside of the asar path.
In both Hydrogen and using a plug-in terminal platform, the default directory is one folder up from where my code file resides.
E.g., I’ll be working on a file with path, say, parent/code/file.py. When I run pwd in the plug-in's terminal or the equivalent via Hydrogen in the python script I get parent/, but I need it to be parent/code/ to import files etc.
Perhaps the default directory for Atom is the project that is folder of the project that is open?
Any ideas how to change the default current directory for Atom (or is it package specific) to the file i’m working on/executing in Hydrogen?
In the hydrogen settings you can choose the location where the kernel should be started.
The default is the 'First started project's directory'. You can choose 'Current directory of the file' there, which should give you what you want.
When debugging with node-inspector, I can see all of the files in a folder except one.
I checked on the filesystem and the .js is there.
Ctrl+O doesn't let me select the file as well.
How can I open the file to place a breakpoint?
Thanks,
PS: I'm using Node Inspector v0.8.0 and node v0.10.33 on a Win7 32 bits
Node Inspector has two mechanisms for loading files in the GUI.
All files loaded by Node.js (V8) runtime are always listed in the GUI, this works very reliably. The downside is that files not loaded yet are not listed. This typically happens when your application is stared via node-debug or node --debug-brk.
There is a speculative algorithm trying to guess what files are part of your project and included them in the GUI even though they are not loaded in the runtime yet. The algorithm assumes that your project has package.json in the root directory and that the main script file is either in the project root directory (node index.js) or one-level deep (node bin/gpii.js). Additionally, if there is package.json in the current working directory, all javascript files in the current working directory and subdirectories are included too.
See lib/ScriptFileStorage.js for more details.
I suspect that your project is laid out in such way that Node Inspector does not recognise it and thus does not scan it for all javascript files.
You can verify this assumption by running the following code in Node Inspector's Console window while the process is paused, replacing ROOT with the real path to your project root:
require('ROOT/universal/gpii/node_modules/flowManager/src/FlowManager.js')
The file FlowManager.js should appear in Node Inspector after the command has finished.