Book a Demo

Author Topic: Start EA over EA.Interop.DLL without active Windows Session  (Read 5213 times)

markoczy

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Start EA over EA.Interop.DLL without active Windows Session
« on: March 20, 2021, 03:37:42 am »
Hello Everyone,

I have read in several other threads (e.g. https://www.sparxsystems.com/forums/smf/index.php/topic,31187.0.html and https://www.sparxsystems.com/forums/smf/index.php?topic=36053.0) that is not possible to start EA over the EA.Interop.DLL without having an active Windows session, however these threads are quite old, so I wanted to ask: Is this still the case with EA Version 15? Or might there be any known possibilities for a workaround to start EA from the SYSTEM user in the context of a Scheduled Task or Service? (without an active Windows Session)

Background: I work for a company that has strong restrictions on their servers that do not allow to have a permanently active Windows Session and my goal is to create a scheduled task that renders diagrams from an EA Project. Any try to achieve this failed, even creating an interactive Session via impersonation over advapi32.dll (Method CreateProcessAsUser). The program I made works perfectly when started by a logged in User but not in context of a Scheduled Task when the option "Run wether user is logged in or not" is set.

I would be very thankful for any hint of someone who has faced this or a similar problem before.

Best Regards
Aleistar

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Start EA over EA.Interop.DLL without active Windows Session
« Reply #1 on: March 20, 2021, 05:37:50 am »
I'm afraid you'll have to have a session one way or another. EA needs to verify the license in order to run, and it can't do that without a user session.

The only "server" component for EA is the Pro Cloud server, but that only has a very limited set of available features.
Hopefully Sparx will expand on that.

I suggest sending in a feature request. The more requests they get, the more likely they will act on it.

Geert

markoczy

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Start EA over EA.Interop.DLL without active Windows Session
« Reply #2 on: March 22, 2021, 06:54:53 pm »
Thanks a lot for the feedback.

Ok then I will have to find another way, I will definitely file in a feature request.

Best Regards
Aleistar

markoczy

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Start EA over EA.Interop.DLL without active Windows Session
« Reply #3 on: March 22, 2021, 08:15:08 pm »
If someone faces the same problem in the Future, here's my Workaround: I create a remote Powershell Session by logging in with another user to localhost. The Script runs from the context of a scheduled task executed by the SYSTEM account (i.e. whether any user is logged in or not), the User that creates the remote Session must have administrator rights:

Code: [Select]
#
# Powershell to run EA Tasks on a "remote Session" on the local Computer
# based on: https://www.faqforge.com/windows/create-powershell-session-remote-computer/
#
# Setup Credentials (Replace "MyUsername" and "MyPassword" with user credentials)
$User = "MyUsername"
$PWord = ConvertTo-SecureString -String "MyPassword" -AsPlainText -Force
Enable-PSRemoting -Force
winrm set winrm/config/client  '@{TrustedHosts=""}'
Restart-Service WinRM
Test-WsMan localhost
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
$sess = New-PSSession -Credential $cred -ComputerName localhost
Enter-PSSession $sess
#
# Inside the remote RPC session
# A C# Program which uses EA.Interop.DLL can be executed here
#
Exit-PSSession
Remove-PSSession $sess

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Start EA over EA.Interop.DLL without active Windows Session
« Reply #4 on: March 22, 2021, 08:31:51 pm »
Nice!

Thanks for the feedback. I'm sure I'll need that one day.

Geert