本文介绍了PowerShell计划任务使用Excel Com对象运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有一些奇怪的行为,我有一个PowerShell脚本将XLSX文件转换为CSV文件。

Here is some strange behavior, I've got a PowerShell script that converts an XLSX file into a CSV file. This script runs in the console without issue.

尝试将任务/脚本调度为没有数据的CSV文件(0个字节)。

Trying to schedule the task/script results in a CSV file with no data (0 Bytes).

在我的搜索中,我发现证明是有帮助的。

In my searching, I found this TechNet forum post that proved helpful.

基本上,包含使用Excel ComObject的Powershell脚本的计划任务失败,因为您必须创建一个文件夹(或64位Windows上的两个)。完成此操作后,手动运行时的任务将按预期运行。当设置触发器并且用户注销时,它也可以工作。

Essentially the scheduled task containing the Powershell script that uses the Excel ComObject fails because You have to create a folder (or two on a 64bit-windows). Once this was done, the task when run manually works as expected. It also works when a trigger is set and the user is logged off.

这种类型的行为涉及到Excel ComObject?我花了3小时试图让这个工作。

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

(64Bit)

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


推荐答案

AFAIK没有MS关于这个问题/限制的官方文档。它应该被报告为一个错误(联系Microsoft支持)。

AFAIK There are no official documentation from MS about this issue/limitation. It should be reported as a bug (contact Microsoft Support).

桌面文件夹(默认情况下没有)的要求不需要excel运行,至少它应该已创建的文件夹,如果丢失。

The requirement of a desktop folder (which SYSTEM doesn't have by default) shouldn't be necessary for excel to run and at least it should have created the folder if missing.

这篇关于PowerShell计划任务使用Excel Com对象运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 00:34