3

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-runner service runs without admin rights as user GitLab-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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.