PowerShell | Word fails to open documents as a background service
System: Windows 2008 Server
Environment: PowerShell + Microsoft.Office.Interop.Word.ApplicationClass (word.application) (as a task in Task Scheduler)
Issue: Word fails to open document in method:
$docxPath = gci "myfile.docx"
$wordApp = New-Object -Com Word.Application
$wordApp.Visible = $false
$wordDoc = $wordApp.Documents.Open($docxPath.FullName)
Solution:
As CRAZY as it sounds, the solution is to CREATE AN EMPTY FOLDER called "Desktop" in either:
C:\Windows\SysWOW64\config\systemprofile\Desktop
or
C:\Windows\System32\config\systemprofile\Desktop
...depending on whether you have 64-bit Windows.
http://stackoverflow.com/questions/1177974/word-interop-not-working-in-a-scheduled-task
Environment: PowerShell + Microsoft.Office.Interop.Word.ApplicationClass (word.application) (as a task in Task Scheduler)
Issue: Word fails to open document in method:
$docxPath = gci "myfile.docx"
$wordApp = New-Object -Com Word.Application
$wordApp.Visible = $false
$wordDoc = $wordApp.Documents.Open($docxPath.FullName)
Solution:
As CRAZY as it sounds, the solution is to CREATE AN EMPTY FOLDER called "Desktop" in either:
C:\Windows\SysWOW64\config\systemprofile\Desktop
or
C:\Windows\System32\config\systemprofile\Desktop
...depending on whether you have 64-bit Windows.
http://stackoverflow.com/questions/1177974/word-interop-not-working-in-a-scheduled-task
Thanks! A silly solution but it worked for me.
ReplyDelete