Rhino _-Export commands hang when started by a service

Hello,
Rhino hangs when calling _-Export “c:\path\to\file.dxf” a second time
Rhino is started by a script running in the background (session 0), so i cannot see what the problem is. To narrow down the problem, i have used File.WriteAllText.
The plugin is working as expected when called by a script from the powershell command, but not when run from a background service.

The file contains many objects in groups spread over several layers.
for each group clear the current selection, then select the objects of the group, and export them
the problem occurs when i export objects the second time using (path beind the dxf file path, i have set _acadschemes, but also fails with ’ _Scheme="2004Natural" _Enter’ , note it is a custom scheme based on “2004 Natural”, not a typo):

string cmd = “_-Export "” + path + “.dxf" _Enter”;
if (!RhinoApp.RunScript(cmd, true)) {/* code to log the error */}

i have tried everything I could think of.
this : RhinoCommon - SaveAs - #6 by stevebaer does not work ( the delegate is not called when it should be).

Also, the same happens with dwg

Switching to Rhino6 is not currently an option.

[update] it seems that it does not hang, but that it is working at a glacial pace (ie. when called in directly it completes within 30s, here it takes well over the timeout limit of 200s)

Does this mean you are using Rhino 5?

– Dale

yes, we still are using rhino 5.
and switching to rhino 6 would imply upgrading the workstations of all colleagues (the plugin has two commands, one interactive with a UI and a non-interactive one with parameters passed trhough the command line)

Please disregard this issue, I found the root cause.
The problem was not from Rhino itself, but from the underlying call.

Should you have this problem, here is how i fixed it (this might help someone) :
The real cause of this problem was the -LoadUserProfile of Start-Process . removing LoadUserProfile fixed the problem.

I do not understand why though, if anyone knows, i would love to find out

Hi @Thierry_BOCK,

Thanks for the update.

– Dale