Archive: Python commands from NSIS


Python commands from NSIS
Hi,

I'm trying to run a Python script from the NSIS installer, but it doesn't work.

Here's my NSIS code:

||
|| NSIS section:
||
|| Section "Main " SEC01
|| SetOutPath "$INSTDIR\"
|| File "C:\Test\ReadMe.txt"
|| File "C:\Test\a.py"
|| ExecWait "C:\Python25\python.exe $INSTDIR\a.py"
|| SectionEnd
||
Here's the code of a.py:

||
|| import os
|| os.remove('C:\Documents and Settings\HP
USER\Desktop\Example1\ReadMe.txt')
||

According to the NSIS logs, the line: "ExecWait
"C:\Python25\python.exe $INSTDIR\a.py" is executed, but the ReadMe.txt
file is not deleted.
I've also tried "ExecWait $INSTDIR\a.py", but it didn't work either.

What am I doing wrong?
Also, is there a way to see the console of the python script that runs
from NSIS?

Please assist.
Thanks in advance!


You need to quote $INSTDIR\a.py as it may contain spaces.
But why use Python to delete a file? You can use the Delete command.


It's just an example to learn how to run .py files in NSIS.
Actually, one of installer tasks is install json-rpc.
String for json-rpc install is: "setup.py install" and I can't do it with NSIS.