---
title: "VB“Automation 错误” 或 “无法定位程序输入点 DoOpenPipeStream 于动态链接库ScrRun.dll上”"
author: "hellostory"
date: "2011-06-30T22:44:00Z"
tags: []
slug: "vb-automation-doopenpipestream-scrrun-dll"
draft: false
lastmod: "2012-02-22T11:13:16Z"
id: 1416479
url: "https://hellostory.iteye.com/blog/1416479"
---

说明：“Automation 错误”其实是VB调用程序或组件时，程序或组件返回的错误，因此需要考虑这些组件是否能正确运行

如在某些机器上运行以下代码时：

会产生“AutoMation 错误”，原因是"Wscript.Shell"无法正常运行

\-------------------------------------------------------------------------------------------------------------------------

以下方法转自网络，已经成功地解决问题！

错误消息和前面的一样“WSript.exe - 无法找到入口 ”，无法创建名为“Wscript.Shell”的对象。于是开始了疯狂百度，原因是说要么脚本被禁用（不可能，因为弹出消息来了嘛），二是文件被改动。网上一般是说注册两个组件就OK了，如下：

regsvr32 srcrun.dll （命令成功）  
regsvr32 wshom.ocx （弹出错误提示：无法定位程序输入点 DoOpenPipeStream 于动态链接库ScrRun.dll上）

前一个执行成功，后一个怎么弄都是错误，消息是“LoadLibary("wshom")失败，找不到指定的程序”，看了看system32目录下，wshom.ocx是有的。后来开始认识到可能是wshom.ocx被破坏了，于是找了相同版本的电脑（我的是XP SP3），然后写段脚本，把下面的文件拷出来：

mkdir c:/repair  
set source=%windir%/system32  
set target=c:/repair  
copy %source%/cscript.exe %target%  
copy %source%/jscript.dll %target%  
copy %source%/scrobj.dll %target%  
copy %source%/scrrun.dll %target%  
copy %source%/vbscript.dll %target%  
copy %source%/wscript.exe %target%  
copy %source%/wshext.dll %target%  
copy %source%/wshom.ocx %target%  
pause

并将对方机器上的c:/repair目录拷贝到我的c:/下，然后用下列脚本更新：

set source=c:/repair  
set target=%windir%/system32  
copy %source%/cscript.exe %target%  
copy %source%/jscript.dll %target%  
copy %source%/scrobj.dll %target%  
copy %source%/scrrun.dll %target%  
copy %source%/vbscript.dll %target%  
copy %source%/wscript.exe %target%  
copy %source%/wshext.dll %target%  
copy %source%/wshom.ocx %target%  
regsvr32 %target%/jscript.dll  
regsvr32 %target%/scrobj.dll  
regsvr32 %target%/scrrun.dll  
regsvr32 %target%/vbscript.dll  
regsvr32 %target%/wshext.dll  
regsvr32 %target%/wshom.ocx  
pause

完成后使用脚本测试CreateObject("WScript.Shell")成功，