Answer the question
In order to leave comments, you need to log in
Is it possible to make win cmd return the path to the directory from where the python application is being launched?
Hello.
There is a need to run a python application through cmd windows. (compiled to exe)
The application uses the output of the result of the work in the log.
The problem is this: when the application starts, the log is always created along the path specified when cmd was started.
I want the logs to fall into the directory with the application, regardless of where it can be transferred and with what parameters cmd starts.
Whether it is possible to implement it somehow?
Answer the question
In order to leave comments, you need to log in
It can be used under win sys.argv[0]
but there are other ways
stackoverflow.com/questions/595305/python-path-of-...
or does it have to be done in a windows batch file?
The best thing to do would be to solve the problem in the application itself, and then recompile it. If the application is not yours and / or there is no way to fix it, you need to run it through a batch file, where the desired directory will be set by the cd command, you can even cd % ~ dp0.
As an option, but this increases the execution time and increases the likelihood of making mistakes, at least for an inexperienced user. The main idea is that my phone will remember the name of the team later. =)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question