Windows administration: automate programs with PowerShell and COM objects

Share your love

Before the .NET framework was invented, Microsoft’s Component Object Model (COM) served as a concept for cross-platform and reusable software. Code that was already written could easily be incorporated into other programs, encapsulated in objects, without having to be compiled into the application. The knowledge of COM still helps some Windows administrators at work today: If you want to automate basic Windows or MS Office functions with PowerShell, you still have to address COM objects. In this article, we will show you how to do this in several small practical examples.

The Component Object Model was introduced in 1992 together with Windows 3.1 under the name Object Linking Embedding (OLE) and renamed COM in 1997 by Microsoft. OLE improved the collaboration between different programs. Among other things, you could integrate Excel tables into a word processor such as Word and still edit the tables with Excel. In addition to OLE, ActiveX is also based on the COM model, which was mainly used in Internet Explorer.

COM components are made available under Windows by run-time modules (DLLs) or executable files (EXE), but also in files with ActiveX controls (OCX). The COM framework only defines a binary interface standard that can be used to create libraries that can be accessed from different languages. Before COM, each programming language needed its own set of libraries: for example, Basic could only use libraries that were written for Basic, and C only those that were written in C. COM allows running applications to release interfaces via which they can be remotely controlled by external programs. This is made possible by two interfaces to the outside world: One is IUnkown, via which the COM component can be queried, and Idispatch, which is used for scripting.

  • Access to all heise + content
  • exclusive tests, advice & background: independent, critically well-founded
  • Read c’t, iX, MIT Technology Review, Mac & i, Make, c’t photography directly in your browser
  • register once – read on all devices – can be canceled monthly
  • first month free, thereafter € 12.95 per month
  • Weekly newsletter with personal reading recommendations from the editor-in-chief

Start FREE month

Start your FREE month now

Already subscribed to heise +?

Sign up and read

Register now and read articles right away

More information about heise +

Article Source

Read Also   Arabia Terra: More than 1000 super volcano eruptions on early Mars
Share your love