Search notes:

PowerShell: Office COM object might leave running process even after calling .Quit()

When an Office COM automation object is created, it might leave a running process after calling .quit(). This is demonstrated in the following example.
First, we verify that there is no running Excel process:
PS C:\> get-process excel 2>$null
The Excel COM-object is created:
PS C:\> $excel = new-object -com excel.application
PS C:\> $excel.visible = $true
Calling quit() on the object makes the GUI of the application disappear:
PS C:\> $excel.quit()
However, the process is still running:
PS C:\> get-process excel 2>$null

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
   1029      52   120980      83156       1.91  11276   1 EXCEL
Setting the variable $excel to $null doesn't eliminate the process, either:
PS C:\> $excel = $null
PS C:\> get-process excel 2>$null
Only removing the variable $excel kills the process:
PS C:\> remove-variable excel
PS C:\> get-process excel 2>$null

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1759407354, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/language/object/COM/Office-process-running-even-after-calling-Quit(64): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78