import os # new
from pathlib import Path
import win32com.client

tempFile = open(os.path.abspath("temp\\temp.py"), 'w')
your_File = 'yourFile.py'
print("import sys\nfrom cx_Freeze import Executable, setup\n\n\nbase = None\nif sys.platform == \"win32\":\n    base = \"Win32GUI\"\nexecutables = [Executable(r\"" + yourFile + "\", base = base)]\n\nsetup(\n    name=\"exe_File\",\n    version=\"0.1\",\n    description=\"Sample cx_Freeze script\",\n    executables=executables,\n)", file = tempFile)
tempFile.close()

os.system("python \"temp\\temp.py\" build")