Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set working directory while launching app from command line #1407

Open
KarthikeyanVedi opened this issue Nov 5, 2018 · 2 comments
Open

Set working directory while launching app from command line #1407

KarthikeyanVedi opened this issue Nov 5, 2018 · 2 comments
Labels
feature:requested Suggestions to enhance the library

Comments

@KarthikeyanVedi
Copy link

KarthikeyanVedi commented Nov 5, 2018

I'm developing an Electron app and using Squirrel for windows installation. I have added the MyApp.exe to PATH pointing to the location %localappdata%\MyApp\MyApp.exe

When the app is run from command line D:\Project\WorkSpace> MyApp the application launches but the working directory of the application is C:\...\AppData\Local\MyApp\app-1.0.0 is it possible to set the working directory of MyApp.exe to D:\Project\WorkSpace ? which is the actual working directory MyApp was run by the user.

I understand that any argument passed to MyApp.exe in the root app directory will be passed to MyApp.exe with in the app-version folder, but can the CWD be set by default without the user having to passing additional args.

@shiftkey
Copy link
Contributor

@KarthikeyanVedi it's not clear to me why the caller needs to change the working directory. Are you able to elaborate on why that's needed for your app?

@shiftkey shiftkey added the feature:requested Suggestions to enhance the library label Apr 25, 2019
@KarthikeyanVedi
Copy link
Author

When you run npm install or npm run, you need to run these command in the root directory of your project where package.json file is present. Here working directory is the root directory of your project.

Similarly my app needs to be executed in a project directory (workspace) where its project specific files are present, this app expects certain config files to present in the workspace root directory.

Currently the issue is, when a user tries to launch the app from a workspace folder like D:\Workspace>MyApp.exe, app is not able to locate any config files present in the D:\Workspace folder instead it looks for file in the folder where the MyApp.exe is installed, the reason being the working directory is changed during ProcessStart by this commit 1438452, but the actual working directory where the user has launched MyApp.exe is D:\WorkSpace

The app need the directory path from where the user has launched MyApp.exe so it can check for its config files in that folder. This path should generally be the Current Working Directory or this path should be passed as an argument during process start. Pull request #1408 fixes this by passing this path as an argument during ProcessStart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:requested Suggestions to enhance the library
Projects
None yet
Development

No branches or pull requests

2 participants