1
Automation Interface, Add-Ins and Tools / Re: Start EA over EA.Interop.DLL without active Windows Session
« 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