【问题标题】:Excel run by VSTS agent from Powershell fails for unknown reasonVSTS 代理从 Powershell 运行的 Excel 因未知原因而失败
【发布时间】:2019-01-17 04:28:28
【问题描述】:

这会很奇怪。

我正在我们的 VSTS 项目中设置构建过程。一切顺利 - 构建过程应该执行 powershell 脚本。 Powershell 脚本已执行 - 但这是问题所在。

脚本创建 Excel 进程并应该打开电子表格文件。它失败并出现以下错误:

Microsoft Excel cannot access the file '-correct path-'. There are several possible
reasons:
 The file name or path does not exist.
 The file is being used by another program.
 The workbook you are trying to save has the same name as a currently open workbook.

不幸的是,它没有任何意义,因为文件确实存在,没有人对电子表格做任何事情,而且访问权限是 - 好吧,我想确保每个人都能完全控制。

更有趣的是,在构建过程中,我打开了 Process Monitor 运行 - 它记录了 Excel 进程对电子表格文件的多次访问 - 但它们都以“SCUCCESS”结束 - 与“ACCESS DENIED”完全不同。

我很困惑,因为它没有意义。此外,我可以直接从 VSTS 代理使用的用户运行脚本,没有问题。

什么可能会干扰这个过程?

【问题讨论】:

  • 私人代理?如果您尝试使用构建列出文件夹的内容会发生什么?你试过调试开关吗?向脚本添加一些日志记录
  • vsts上是用host build agent还是private build agent,有没有仔细检查过build service账号的相关权限,应该是build service账号运行powershell脚本启动excel。如果您使用的是私有代理,也请尝试远程构建代理并直接运行脚本以缩小问题范围。
  • 你的脚本是什么?
  • 您的代理是否作为交互式服务运行?

标签: excel windows powershell azure-devops


【解决方案1】:

对于 x64 机器,创建以下目录: C:\Windows\SysWOW64\config\systemprofile\Desktop

确保代理帐户对C:\Windows\SysWOW64\config\ 文件夹、C:\Windows\SysWOW64\config\systemprofile 文件夹和C:\Windows\SysWOW64\config\systemprofile\Desktop 文件夹具有完全访问控制权。

更多详情见: https://blogs.msdn.microsoft.com/dataaccesstechnologies/2012/12/19/error-microsoft-office-excel-cannot-access-the-file-while-accessing-microsoft-office-11-0-object-library-from-ssis/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-21
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 2017-10-27
    相关资源
    最近更新 更多