Open and Write Word-ComObject on Win2k8 Server via Powershell failed
Hello
we run the TeamCity Build Service on a Win 2008 Server Machine. My task is to open a Word Document and write several words and sentences. Afterwards the document should be closed automatically.
The TeamCity Process executes a MS Build.xml File. In this file i open a powershell. This Powershell is assigend to open a Word -Com Object and write some words as i mentioned before.
When I execute the Powershell on a local computer oder manually on the server it works highly well. But when the powershell-script is executed via the TeamcityService and the MSBuild.xml File the following error is shown:
[Exec] You cannot call a method on a null-valued expression.
[Exec] At C:\Firmwarebuilds\G8-IAX\branches\S-PUE\BS\CurrentPath.ps1:23 char:25
[Exec] + $Selection.Find.Execute <<<< (
[Exec] + CategoryInfo : InvalidOperation: (Execute:String) [], RuntimeException
[Exec] + FullyQualifiedErrorId : InvokeMethodOnNull
Is it possible that the TeamCity Service has not enough permissions to execute a Powershell or to open a –Com Object ?
Are there anywhere on the Server settings to allow the Powershell to interact (open/write/close/…) a Word File?
As I already mentioned before when I execute the Powershell Script manually it works well.
Sincerly
Lukas
Please sign in to leave a comment.
Hi Lukas
Microsoft Office automation is not officially supported to work under services. See KB257757 for details.
Also here is a related thread in Microsoft forums.
To prove that, try to run build agent interactivelly within your logon session by agent.bat
Michael
Hello Michael,
thank you for your information. Do you have other ideas wheter it is possible to write a Document or somthing like that automatically on a Server? Or are there alternatives to Powershell ?
Greetz
Lukas
KB artikle I mentioned above lists a number of alternatives.
Have you tried to run the build agent interactivelly? Did it change the behavior?