VBS暂停并没有错误 [英] VBS halts with out error

查看:79
本文介绍了VBS暂停并没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个创建并调用批处理文件的脚本.它运行17条命令,然后冻结.如果我退出脚本并运行它创建的批处理文件,则可以正常运行.命令行基于IIS网站.如果我删除故障点附近的网站并运行脚本,它仍然可以正确处理17个命令(也是17个网站).有什么想法吗?这是脚本:

Const ForReading = 1
Const ForWritting = 2
Const ForAppending = 8

I have a script that creates and calls a batch file.  It runs through 17 commands and then freezes.  If I exit the script and run the batch file it created, it runs fine.  The command lines are based on IIS websites.  If I remove the websites surrounding the point of failure and run the script, it still processes exactly 17 command (which is also 17 websites.)  Any ideas?  Here is the script:

Const ForReading = 1
Const ForWritting = 2
Const ForAppending = 8

设置fso = CreateObject("Scripting.FileSystemObject")
设置strFile = fso.OpenTextFile("D:\ BatchJobs \ WebSiteSync \ sites.txt",ForReading)
设置strCommand = fso .OpenTextFile("D:\ BatchJobs \ WebSiteSync \ Sync.bat",ForWriting)
set strLog = fso.openTextFile("D:\ BatchJobs \ WebSiteSync \ msdeploysync.log",ForWritting)

Set fso = CreateObject("Scripting.FileSystemObject")
Set strFile = fso.OpenTextFile("D:\BatchJobs\WebSiteSync\sites.txt", ForReading)
Set strCommand = fso.OpenTextFile("D:\BatchJobs\WebSiteSync\Sync.bat", ForWritting)
set strLog = fso.openTextFile("D:\BatchJobs\WebSiteSync\msdeploysync.log", ForWritting)

strLog.WriteLine Date()& " " & Time()
strLog.WriteLine呼叫创建网站列表"

strLog.WriteLine Date() & " " & Time()
strLog.WriteLine "Calling Creation of Web Site List"


Dim oWsc,oExec
设置oWsc = CreateObject("WScript.Shell")
设置oExec = oWsc.Exec("D:\ BatchJobs \ WebSiteSync \ CreateList.bat"" ;)
'等到完成
在oExec.Status<>期间执行1
WScript.Sleep 100
循环


Dim oWsc, oExec
Set oWsc = CreateObject("WScript.Shell")
Set oExec = oWsc.Exec("D:\BatchJobs\WebSiteSync\CreateList.bat")
' wait until finished
Do While oExec.Status <> 1
WScript.Sleep 100
Loop

strLog.WriteLine错误编号& " " & err.description
err.number = 0
strLog.WriteLine
strLog.WriteLine读取网站"
strLog.WriteLine

strLog.WriteLine err.number & " " & err.description
err.number = 0
strLog.WriteLine
strLog.WriteLine "Reading WebSites"
strLog.WriteLine

strCommand.WriteLine" msdeploy -verb:sync -source:appPoolConfig -dest:appPoolConfig,computerName = IISServer2"
执行直到strFile.AtEndOfStream
s = strFile.ReadLine
x = Instr(s,chr(34))
如果x> 0 then
SiteName = right(s,len(s)-x)
结束,如果
y = Instr(SiteName,chr(34))
如果y> 0则
SiteName = left(SiteName,y-1)
如果if
如果SiteName<> 默认网站"然后
strCommand.WriteLine" msdeploy -verb:sync -source:apphostconfig =" & chr(34)&网站名称和chr(34)& ",includeAcls = true -dest:apphostconfig =" & chr(34)&网站名称和chr(34)& " computerName = IISServer2 -debug -verbose>> D:\ BatchJobs \ WebSiteSync \ msdeploysync.log;
如果结束
循环

strCommand.WriteLine "msdeploy -verb:sync -source:appPoolConfig -dest:appPoolConfig,computerName=IISServer2"
Do Until strFile.AtEndOfStream
 s = strFile.ReadLine
 x = Instr(s, chr(34))
 if x > 0 then
  SiteName = right(s, len(s) - x)
 end if
 y = Instr(SiteName, chr(34))
 if y > 0 then
  SiteName = left(SiteName,y-1)
 end if
 if SiteName <> "Default Web Site" then
  strCommand.WriteLine "msdeploy -verb:sync -source:apphostconfig=" & chr(34) & SiteName & chr(34) & ",includeAcls=true -dest:apphostconfig=" & chr(34) & SiteName & chr(34) & ",computerName=IISServer2 -debug -verbose >> D:\BatchJobs\WebSiteSync\msdeploysync.log"
 end if
loop

strLog.WriteLine调用Sync.bat"
strLog.WriteLine

strLog.WriteLine "Calling Sync.bat"
strLog.WriteLine


strFile.Close
strCommand.Close
strLog.close


strFile.Close
strCommand.Close
strLog.close

设置oExec = oWsc.Exec("D:\ BatchJobs \ WebSiteSync \ Sync.bat"). 1
WScript.Sleep 30000
循环

Set oExec = oWsc.Exec("D:\BatchJobs\WebSiteSync\Sync.bat")
Do While oExec.Status <> 1
WScript.Sleep 30000
Loop

set strLog = fso.openTextFile("D:\ BatchJobs \ WebSiteSync \ msdeploysync.log",用于附加)
strLog.WriteLine完成于" & Date()& " " & Time()
strLog.close

set strLog = fso.openTextFile("D:\BatchJobs\WebSiteSync\msdeploysync.log", ForAppending)
strLog.WriteLine "Finished at " & Date() & " " & Time()
strLog.close

推荐答案

PS这是批处理文件中一行的示例.大约有80个类似的网站,每个网站都不同. = IISServer2 -debug -verbose>> D:\ BatchJobs \ WebSiteSync \ msdeploysync.log
PS here is an example of a line in the batch file.  There are about 80 like this, each with a different website.

msdeploy -verb:sync -source:apphostconfig="CALENDAR",includeAcls=true -dest:apphostconfig="CALENDAR",computerName=IISServer2 -debug -verbose >> D:\BatchJobs\WebSiteSync\msdeploysync.log


这篇关于VBS暂停并没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆