0

I am trying to run FreeCAD, a CAD application, through python. You can control it through the command line by providing a script (pyhthon) to the executable. The problem is that you need administrative privileges to run the .exe file. So what I do in Windows, is the following.

I open CMD as an administrator, and then I type:

"C:\Program Files\FreeCAD 0.18\bin\FreeCADCmd.exe" -l "C:\Users\Henry\Desktop\cylinder_macro.py"

This works! However, I am having difficulties making it work from python.I am trying to implement what has been suggested in this post: Run process as admin with subprocess.run in python

import subprocess
prog = subprocess.run(['runas', '/noprofile', '/user:Administrator', "C:\\Program Files\\FreeCAD 0.18\\bin\\FreeCADCmd.exe","C:\\Users\\Henry\\Desktop\\cylinder_macro.py"])

It does not work. If I print prog, I get:

CompletedProcess(args=['runas', '/noprofile', '/user:Administrator', 'C:\\Program Files\\FreeCAD 0.18\\bin\\FreeCADCmd.exe', 'C:\\Users\\Dorian\\Henry\\cylinder_macro.py'], returncode=1)

Any ideas of how to get this to work are highly appreciated

henry
  • 875
  • 1
  • 18
  • 48

0 Answers0