s3调用powershell操作office时各种报错

您所在的位置:网站首页 powershell教程下载 s3调用powershell操作office时各种报错

s3调用powershell操作office时各种报错

2023-03-15 06:22| 来源: 网络整理| 查看: 265

as3调用powershell操作office时各种报错

我前边一共还提过三个问题都是指向这个问题的(悬赏75rmb),至今还未采纳,谁帮我解决了我回复您,您再去前面几个一起回复一下,我一并给您采纳了。通过as3调用ps1脚本操作office,ps1脚本在A电脑上写的,内容也不复杂,不外乎就是对word和excel进行一些常见的操作(比如写数据,调整格式),已经在写代码的那台win7电脑A上测试过一切OK,但是拿到B,C,D电脑上就各种诡异报错,经过三天的排查,初步查出是powershell环境的问题。甚至连使用SaveAS命令都会报错。比如,B电脑对下面这一步报错,

$selection.EndKey([Microsoft.Office.Interop.Word.WdUnits]::wdStory)

C电脑对下面这一句报错

```bash $doc.SaveAs([ref]"C:\myMergeDoc.docx") D电脑对下面这一句报错 ```bash $pdffile="C:\test.pdf" $doc.SaveAs([ref] $pdffile, [ref] 17)

经过三天排查,怀疑是与powershell的环境有关,我分别在A(正常),B(不正常),C(正常)电脑运行了以下几个命令:

获得的信息如下:

A电脑可以正常运行

img

img

img

img

img

B电脑不能正常运行

img

img

img

img

C电脑能正常运行

img

img

img

img

img

img

DCOM也按照教程设置过了,ps1脚本文件的权限都设置过了,应该就是环境的问题了。相信明眼人一眼就能看出B电脑缺了什么,我是PS小bai,请告诉我详细的解决步骤,先谢

以下是之前提问的请参考其中报错信息: https://ask.csdn.net/questions/7899716

```bash F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\myDoc.docx 参数1 C:/Users/Administrator/Documents/excel.tmp 参数2 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\myResources\2023年3月12日 参数3 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.doc x 参数4 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.pdf 参数5 2023年3月12日作业报告______①12点36分27秒—12点37分36秒______②耗时0时1分9秒;____ __③共测试3人 PS echo success 0002 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\myResources\2023年3月12日 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\myResources\2023年3月12日\朱熹_2023年3月12日12点37分22秒.docx process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:47 字符: 32 + $doc = $word.Documents.Open $docxFile.FullName) + CategoryInfo : NotSpecified: (:) [], MethodException process error : + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:48 字符: 24 + $doc.Content.Select error : eption + FullyQualifiedErrorId : InvokeMethodOnNull process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:49 字符: 22 process error :+ $doc.Content.Copy error : + CategoryInfo : InvalidOperation: (Copy:String) [], RuntimeExcep process error : tion process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:50 字符: 15 process error :+ $doc.Close error : + FullyQualifiedErrorId : DotNetMethodException process error : process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:53 字符: 32 + $doc = $word.Documents.Open $outputFile) + CategoryInfo : NotSpecified: (:) [], MethodException process error : + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.doc x process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:56 字符: 25 process error :+ $mySelection.HomeKey error : + CategoryInfo : InvalidOperation: (HomeKey:String) [], RuntimeEx process error : ception process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:57 字符: 31 + $mySelection.InsertNewPage error : + CategoryInfo : InvalidOperation: (InsertNewPage:String) [], Run timeException + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:58 字符: 25 + $mySelection.HomeKey error : + CategoryInfo : InvalidOperation: (HomeKey:String) [], RuntimeEx process error : ception process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:59 字符: 23 + $mySelection.Paste error : ption + FullyQualifiedErrorId : InvokeMethodOnNull process error :使用“0”个参数调用“Save”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 process error :HRESULT:0x80010108 (RPC_E_DISCONNECTED))” 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:60 字符: 14 process error :+ $doc.Save error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 process error : HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:61 字符: 15 + $doc.Close error : + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException process error : F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\myResources\2023年3月12日\杨炎_2023年3月12日12点36分46秒.docx process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:47 字符: 32 + $doc = $word.Documents.Open $docxFile.FullName) process error : + CategoryInfo : NotSpecified: (:) [], MethodException + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:48 字符: 24 + $doc.Content.Select error : + CategoryInfo : InvalidOperation: (Select:String) [], RuntimeExc eption + FullyQualifiedErrorId : InvokeMethodOnNull process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:49 字符: 22 + $doc.Content.Copy error : + CategoryInfo : InvalidOperation: (Copy:String) [], RuntimeExcep tion + FullyQualifiedErrorId : InvokeMethodOnNull process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 HRESULT:0x80010108 (RPC_E_DISCONNECTED))” 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:50 字符: 15 + $doc.Close error : process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:53 字符: 32 process error :+ $doc = $word.Documents.Open $outputFile) + CategoryInfo : NotSpecified: (:) [], MethodException + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.doc x process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:56 字符: 25 process error :+ $mySelection.HomeKey error :ry) #光标移动到文首 + CategoryInfo : InvalidOperation: (HomeKey:String) [], RuntimeEx ception process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:57 字符: 31 process error :+ $mySelection.InsertNewPage Run timeException process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:58 字符: 25 + $mySelection.HomeKey error :ry) #插入空白页之后重新将光标移动到文首 + CategoryInfo : InvalidOperation: (HomeKey:String) [], RuntimeEx process error : ception + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :不能对值为空的表达式调用方法。 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:59 字符: 23 + $mySelection.Paste error : + CategoryInfo : InvalidOperation: (Paste:String) [], RuntimeExce process error : ption process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :使用“0”个参数调用“Save”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 process error :HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:60 字符: 14 process error :+ $doc.Save error : process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 process error : HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:61 字符: 15 + $doc.Close error : + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException process error : F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\myResources\2023年3月12日\葛洪_2023年3月12日12点37分3秒.docx process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:47 字符: 32 process error :+ $doc = $word.Documents.Open $docxFile.FullName) process error : + CategoryInfo : NotSpecified: (:) [], MethodException process error : + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg process error : process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:48 字符: 24 process error :+ $doc.Content.Select error : + CategoryInfo : InvalidOperation: (Select:String) [], RuntimeExc eption process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error :不能对值为空的表达式调用方法。 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:49 字符: 22 + $doc.Content.Copy error : process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 process error : HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:50 字符: 15 process error :+ $doc.Close error : + CategoryInfo : NotSpecified: (:) [], MethodInvocationException process error : + FullyQualifiedErrorId : DotNetMethodException process error : process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:53 字符: 32 + $doc = $word.Documents.Open $outputFile) + CategoryInfo : NotSpecified: (:) [], MethodException process error : + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.doc x process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:56 字符: 25 + $mySelection.HomeKey error :ry) #光标移动到文首 + CategoryInfo : InvalidOperation: (HomeKey:String) [], RuntimeEx ception + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :不能对值为空的表达式调用方法。 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:57 字符: 31 process error :+ $mySelection.InsertNewPage Run timeException + FullyQualifiedErrorId : InvokeMethodOnNull process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:58 字符: 25 + $mySelection.HomeKey error :ry) #插入空白页之后重新将光标移动到文首 + CategoryInfo : InvalidOperation: (HomeKey:String) [], RuntimeEx ception process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:59 字符: 23 process error :+ $mySelection.Paste error : + CategoryInfo : InvalidOperation: (Paste:String) [], RuntimeExce ption + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :使用“0”个参数调用“Save”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 process error :HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:60 字符: 14 + $doc.Save error : + FullyQualifiedErrorId : DotNetMethodException process error : process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 process error : HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:61 字符: 15 process error :+ $doc.Close error : + FullyQualifiedErrorId : DotNetMethodException process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:65 字符: 32 + $doc = $word.Documents.Open $outputFile) + CategoryInfo : NotSpecified: (:) [], MethodException + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:67 字符: 24 + $mySelection.EndKey error : + CategoryInfo : InvalidOperation: (EndKey:String) [], RuntimeExc eption process error : + FullyQualifiedErrorId : InvokeMethodOnNull process error :不能对值为空的表达式调用方法。 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:68 字符: 31 process error :+ $mySelection.TypeBackspace Run process error : timeException + FullyQualifiedErrorId : InvokeMethodOnNull process error :不能对值为空的表达式调用方法。 process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:69 字符: 31 process error :+ $mySelection.TypeBackspace error : + CategoryInfo : InvalidOperation: (TypeBackspace:String) [], Run timeException + FullyQualifiedErrorId : InvokeMethodOnNull process error : process error :使用“16”个参数调用“SaveAs”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来 process error :自 HRESULT:0x80010108 (RPC_E_DISCONNECTED))” 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:72 字符: 16 + $Doc.SaveAs $pdffile, [ref] 17) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException process error :使用“16”个参数调用“SaveAs”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来 process error :自 HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr iteMyDoc.ps1:74 字符: 16 process error :+ $doc.SaveAs $outputFile) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException process error : + FullyQualifiedErrorId : DotNetMethodException process error : process error :使用“0”个参数调用“Save”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 process error :HRESULT:0x80010108 (RPC_E_DISCONNECTED))” process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:75 字符: 14 + $doc.Save error : + CategoryInfo : NotSpecified: (:) [], MethodInvocationException process error : + FullyQualifiedErrorId : DotNetMethodException process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 HRESULT:0x80010108 (RPC_E_DISCONNECTED))” 所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr process error :iteMyDoc.ps1:76 字符: 15 + $doc.Close

```



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3