code: def temp_file(self):
          
          with tempfile.NamedTemporaryFile(suffix='.bat', delete=False) as fp:
              try:
                  logger.debug("Saving code to %r", fp.name)
                  fp.write(self.code.encode('utf-8'))
                  fp.close()
                  yield fp.name
              finally:
                  os.remove(fp.name)
docs: Create temporary file with code and yield its path.
          Works both on Windows and Linux