NSIS CopyFiles not working for .py files

179 views Asked by At

I am creating an installer for a Python program using NSIS. I have to copy the source files to C:\Program Files\Snakecharmer, so I am first making sure it is created, then copying the source files to C:\Program Files\Snakecharmer. There are three .py files that I am copying, plus __pycache__, and some other things.

The contents of __pycache__ are copied, but they do not stay in __pycache__, they are just copied loose into the directory. The three .py files are not copied at all. Everything else copies correctly.

Here is my code

CopyFiles "$R0\SnakeCharmer.py" "$INSTDIR"
CopyFiles "$R0\snakecharmerupdater.py" "$INSTDIR"
CopyFiles "$R0\cobracrypt.py" "$INSTDIR"
CopyFiles "$R0\__pycache__" "$INSTDIR"
CopyFiles "$R0\Run_SnakeCharmer.bat" "$INSTDIR"
CopyFiles "$R0\icon.ico" "$INSTDIR"
CopyFiles "$R0\SnakeCharmer.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs"

The first three are the .py files that didn't copy.

Why is this happening and how can I fix it?

1

There are 1 answers

0
Anders On BEST ANSWER

NSIS uses SHFileOperation internally, there is no special handling of any file types. Just make sure the destination directory exists before you start the operation: CreateDirectory "$InstDir"

Process Monitor will probably give you some clues as to why it fails...