I'm trying to automate some things via GitLab pipelines for TwinCAT (PLC development tool, based on Visual Studio Shell).
- I have a windows runner, trying to automate things with powershell scripts
- the
gitlab-runnerservice runs without admin rights as userGitLab-Runner
I try to get a COM object to use the Automation Interface for TwinCAT:
# ======== JOB: release library ========
release-library:
stage: deploy
script:
# debug test
- |
$Dte = New-Object -ComObject 'TcXaeShell.DTE.15.0'
but I get this error if I execute the pipeline:
$ $Dte = New-Object -ComObject 'TcXaeShell.DTE.15.0'
New-Object : Retrieving the COM class factory for component with CLSID
{A731B066-C381-4701-926E-AF470E987D80} failed due to the following error: 80070005 Access is
denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
At line:280 char:8
+ $Dte = New-Object -ComObject 'TcXaeShell.DTE.15.0'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-Object], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.Ne
wObjectCommand
If I start powershell directly on the runner as user GitLab-Runner and execute the same line of code
$Dte = New-Object -ComObject 'TcXaeShell.DTE.15.0'
it works without any issues.
I identified the CLSID {A731B066-C381-4701-926E-AF470E987D80} in the registry:
ProgId TcXaeShell.DTE.15.0
LocalServer32 C:\Program Files (x86)\Beckhoff\TcXaeShell\Common7\IDE\TcXaeShell.exe
I tried to give the user all rigts for C:\Program Files (x86)\Beckhoff\TcXaeShell but nothing changed.
I testet the runner service with admin rights, and is is working.
I'm quite new to GitLab pipelines and COM objects... What is the difference between the runner environment and if I start powershell as the same user?
I would be grateful for any tips on what else I could test.