0

As part of my C code I run python script,(one of the .dll files runs the script)

getcwd(directory);
ret_value = ShellExecute(NULL,NULL,"myScript.py",NULL,directory,0);

This is the folder of the program after build.

If I run the .exe from the folder every thing works.

The bug: If I search program .exe outside the folder and run it the script doesn't run.

msgVbug.png

Search: If I run it from here the script doesn't run. Capturesearch.png

3
  • 4
    It's looking for the script in the current working directory which obviously is not what you think it is. Try using an absolute path, or find the absolute path some other way programatically. Commented Aug 17, 2016 at 6:53
  • Thank you @Joachim Pileborg,how can I find absolute path at the run time?I can not hardcode it, it won't work.. Commented Aug 17, 2016 at 8:09
  • @David You should not edit the answer into the question. Instead post your own answer (possibly more complete than just "use this function") and accept it. Commented Aug 18, 2016 at 13:44

1 Answer 1

1

GetModuleFileNameW() function retrieves the fully qualified path for the file that contains the specified module. This way you can find absolute path of the .dll and use _chdir and change the current working directory to that path.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.