Powershell script cannot access a file when run as a Scheduled Task

前端 未结 3 1396
别跟我提以往
别跟我提以往 2020-12-09 11:07

My Powershell (2.0) script has the following code snippet:

$fileName = \"c:\\reports\\1.xlsx\"
$xl = new-object -comobject excel.application
$xlFormat = [Mic         


        
3条回答
  •  余生分开走
    2020-12-09 11:37

    I think you've hit a bug in Excel:

    You have to create a folder (or two on a 64bit-windows):

    (32Bit, always)

    C:\Windows\System32\config\systemprofile\Desktop

    (64Bit)

    C:\Windows\SysWOW64\config\systemprofile\Desktop

    I have had the same problem and this was the only solution i have found.

    From TechNet Forums (via PowerShell and Excel Issue when Automating )

提交回复
热议问题