![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | VBScript halts with out error message 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 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 "Calling Creation of Web Site List" 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.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" 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 "Calling Sync.bat" strLog.WriteLine strFile.Close strCommand.Close strLog.close 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", ForAppending) strLog.WriteLine "Finished at " & Date() & " " & Time() strLog.close |
My System Specs![]() |
| | #2 (permalink) |
| | Re: VBScript halts with out error message "Dan" <Dan@xxxxxx> wrote in message news:F4697881-9ED9-4829-9791-1B5D87249F0F@xxxxxx Quote: >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 > > 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 "Calling Creation of Web Site List" > > > 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.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" > 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 Quote: Quote: > >> > end if > loop > > strLog.WriteLine "Calling Sync.bat" > strLog.WriteLine > > > strFile.Close > strCommand.Close > strLog.close > > 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", > ForAppending) > strLog.WriteLine "Finished at " & Date() & " " & Time() > strLog.close has completed its operation. Use the Run method instead - it accepts an optional parameter bWaitOnReturn. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: VBScript halts with out error message I cahnged the call line to: Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "D:\BatchJobs\WebSiteSync\Sync.bat",0,bWaitOnReturn But despite numerous arrangements of the .run line with varied parameters, it will not wait for the called job to complete before it goes on to the next line. "Pegasus [MVP]" wrote: Quote: > > "Dan" <Dan@xxxxxx> wrote in message > news:F4697881-9ED9-4829-9791-1B5D87249F0F@xxxxxx Quote: > >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 > > > > 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 "Calling Creation of Web Site List" > > > > > > 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.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" > > 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 Quote: > > >> > > end if > > loop > > > > strLog.WriteLine "Calling Sync.bat" > > strLog.WriteLine > > > > > > strFile.Close > > strCommand.Close > > strLog.close > > > > 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", > > ForAppending) > > strLog.WriteLine "Finished at " & Date() & " " & Time() > > strLog.close > The Exec method is not suitable when you need to wait until a shell command > has completed its operation. Use the Run method instead - it accepts an > optional parameter bWaitOnReturn. > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: VBScript halts with out error message On Apr 20, 11:48*am, Dan <D...@xxxxxx> wrote: Quote: > I cahnged the call line to: > > Set WshShell = WScript.CreateObject("WScript.Shell") > WshShell.Run "D:\BatchJobs\WebSiteSync\Sync.bat",0,bWaitOnReturn > > But despite numerous arrangements of the .run line with varied parameters, > it will not wait for the called job to complete before it goes on to the next > line. > > "Pegasus [MVP]" wrote: > Quote: > > "Dan" <D...@xxxxxx> wrote in message > >news:F4697881-9ED9-4829-9791-1B5D87249F0F@xxxxxx Quote: > > >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: Quote: Quote: > > > Const ForReading = 1 > > > Const ForWritting = 2 > > > Const ForAppending = 8 Quote: Quote: > > > 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) Quote: Quote: > > > strLog.WriteLine Date() & " " & Time() > > > strLog.WriteLine "Calling Creation of Web Site List" Quote: Quote: > > > 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 Quote: Quote: > > > strLog.WriteLine err.number & " " & err.description > > > err.number = 0 > > > strLog.WriteLine > > > strLog.WriteLine "Reading WebSites" > > > strLog.WriteLine Quote: Quote: > > > 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 Quote: Quote: > > > D:\BatchJobs\WebSiteSync\msdeploysync.log" > > > end if > > > loop Quote: Quote: > > > strLog.WriteLine "Calling Sync.bat" > > > strLog.WriteLine Quote: Quote: > > > strFile.Close > > > strCommand.Close > > > strLog.close Quote: Quote: > > > Set oExec = oWsc.Exec("D:\BatchJobs\WebSiteSync\Sync.bat") > > > Do While oExec.Status <> 1 > > > WScript.Sleep 30000 > > > Loop Quote: Quote: > > > set strLog = fso.openTextFile("D:\BatchJobs\WebSiteSync\msdeploysync.log", > > > ForAppending) > > > strLog.WriteLine "Finished at " & Date() & " " & Time() > > > strLog.close Quote: > > The Exec method is not suitable when you need to wait until a shell command > > has completed its operation. Use the Run method instead - it accepts an > > optional parameter bWaitOnReturn. First, you need to define the value of bWaitOnReturn: True means wait and false (default) means don't wait. Commonly this is done with a literal, rather than a variable (unless it is programatically important to be a variable). So, you probably want ... Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "D:\BatchJobs\WebSiteSync\Sync.bat",0,True However, the Exec.Status checks and looping you had in your original script should have worked in fundamentally the same way. Therefore, I must conclude that the underlying operations contained in your batch procedures are the source of your problem. Since you didn't post those, it's hard to be sure, but from your description, I can't imagine anything else. Specifically, if an application invoked in one or more of the batch files is a Win32 application or is launching an additional thread and then terminating, the batch procedures would end and return control to your script, even while the application continues to run. To get this behavior under control, a START statement to launch the offending application(s) in the batch may be all that is needed. However, it might be harder than that. I think some insight into the batch procedures may be needed to solve your problem. Tom Lavedas *********** http://there.is.no.more/tglbatch/ |
My System Specs![]() |
| | #5 (permalink) |
| | Re: VBScript halts with out error message T Lavedas schrieb: Quote: > On Apr 20, 11:48 am, Dan <D...@xxxxxx> wrote: Quote: >> I cahnged the call line to: >> >> Set WshShell = WScript.CreateObject("WScript.Shell") >> WshShell.Run "D:\BatchJobs\WebSiteSync\Sync.bat",0,bWaitOnReturn >> >> But despite numerous arrangements of the .run line with varied parameters, >> it will not wait for the called job to complete before it goes on to the next >> line. >> >> "Pegasus [MVP]" wrote: >> Quote: >>> "Dan" <D...@xxxxxx> wrote in message >>> news:F4697881-9ED9-4829-9791-1B5D87249F0F@xxxxxx >>>> 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 >>>> 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 "Calling Creation of Web Site List" >>>> 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.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" >>>> 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 "Calling Sync.bat" >>>> strLog.WriteLine >>>> strFile.Close >>>> strCommand.Close >>>> strLog.close >>>> 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", >>>> ForAppending) >>>> strLog.WriteLine "Finished at " & Date() & " " & Time() >>>> strLog.close >>> The Exec method is not suitable when you need to wait until a shell command >>> has completed its operation. Use the Run method instead - it accepts an >>> optional parameter bWaitOnReturn. > Dan, > > First, you need to define the value of bWaitOnReturn: True means wait > and false (default) means don't wait. Commonly this is done with a > literal, rather than a variable (unless it is programatically > important to be a variable). So, you probably want ... > > Set WshShell = WScript.CreateObject("WScript.Shell") > WshShell.Run "D:\BatchJobs\WebSiteSync\Sync.bat",0,True > > However, the Exec.Status checks and looping you had in your original > script should have worked in fundamentally the same way. Therefore, I > must conclude that the underlying operations contained in your batch > procedures are the source of your problem. Since you didn't post > those, it's hard to be sure, but from your description, I can't > imagine anything else. Specifically, if an application invoked in one > or more of the batch files is a Win32 application or is launching an > additional thread and then terminating, the batch procedures would end > and return control to your script, even while the application > continues to run. To get this behavior under control, a START > statement to launch the offending application(s) in the batch may be > all that is needed. However, it might be harder than that. > > I think some insight into the batch procedures may be needed to solve > your problem. > > Tom Lavedas > *********** > http://there.is.no.more/tglbatch/ '' starter.vbs - start [a]sync.bat Option Explicit Dim sCmd : sCmd = ".\sync.bat" Dim oWSH : Set oWSH = CreateObject( "WScript.Shell" ) Dim oWAN : Set oWAN = WScript.Arguments.Named If oWAN.Exists( "async" ) Then sCmd = ".\async.bat" WScript.Echo "starter started" WScript.Echo "starting", sCmd Dim iRet : iRet = oWSH.Run( "%comspec% /c " & sCmd, 1, True ) WScript.Echo "iRet =", iRet WScript.Echo "starter terminated" WScript.Quit 0 to start either: @ECHO OFF REM sync.bat - running worker.vbs ECHO sync.bat started ECHO running worker.vbs cscript worker.vbs 10000 ECHO sync.bat terminated for a synchron run or @ECHO OFF REM async.bat - kicking off worker.vbs ECHO async.bat started ECHO kicking off worker.vbs start cscript worker.vbs 10000 ECHO sync.bat terminated for an asynchron kick off of: '' worker.vbs - working for some time Option Explicit Dim nSleeps : nSleeps = 5000 Dim oWAU : Set oWAU = WScript.Arguments.UnNamed If 1 = oWAU.Count Then If IsNumeric( oWAU( 0 ) ) Then nSleeps = CInt( oWAU( 0 ) ) End If End If WScript.Echo "Worker started" Dim nStep : nStep = nSleeps \ 5 Do Until nSleeps < 0 WScript.Echo "Working ..." WScript.Sleep nStep nSleeps = nSleeps - nStep Loop WScript.Echo "worker terminated" WScript.Quit 0 you get a live demonstration of Tom's theoretical explanation. |
My System Specs![]() |
| | #6 (permalink) |
| | Re: VBScript halts with out error message Changing to your call with "true" instead of the bWaitOnReturn seems to have fixed it, however if you think there might be an issue with the batch file, the commands look like this. The first line is unique and just copies the app pools. The next two lines show it moving two websites, it will be repeated maybe 40 times each with a different website name. the batch job which is created and called looks like this:msdeploy -verb:sync -source:appPoolConfig -dest:appPoolConfig,computerName=IISServer2 msdeploy -verb:sync -source:apphostconfig="CAPCAL",includeAcls=true -dest:apphostconfig="Web1",computerName=IISServer2 -debug -verbose >> D:\BatchJobs\WebSiteSync\msdeploysync.log msdeploy -verb:sync -source:apphostconfig="RAMPUP",includeAcls=true -dest:apphostconfig="Web2",computerName=IISServer2 -debug -verbose >> D:\BatchJobs\WebSiteSync\msdeploysync.log "T Lavedas" wrote: Quote: > On Apr 20, 11:48 am, Dan <D...@xxxxxx> wrote: Quote: > > I cahnged the call line to: > > > > Set WshShell = WScript.CreateObject("WScript.Shell") > > WshShell.Run "D:\BatchJobs\WebSiteSync\Sync.bat",0,bWaitOnReturn > > > > But despite numerous arrangements of the .run line with varied parameters, > > it will not wait for the called job to complete before it goes on to the next > > line. > > > > "Pegasus [MVP]" wrote: > > Quote: > > > "Dan" <D...@xxxxxx> wrote in message > > >news:F4697881-9ED9-4829-9791-1B5D87249F0F@xxxxxx > > > >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: Quote: > > > > Const ForReading = 1 > > > > Const ForWritting = 2 > > > > Const ForAppending = 8 Quote: > > > > 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) Quote: > > > > strLog.WriteLine Date() & " " & Time() > > > > strLog.WriteLine "Calling Creation of Web Site List" Quote: > > > > 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 Quote: > > > > strLog.WriteLine err.number & " " & err.description > > > > err.number = 0 > > > > strLog.WriteLine > > > > strLog.WriteLine "Reading WebSites" > > > > strLog.WriteLine Quote: > > > > 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 Quote: > > > > D:\BatchJobs\WebSiteSync\msdeploysync.log" > > > > end if > > > > loop Quote: > > > > strLog.WriteLine "Calling Sync.bat" > > > > strLog.WriteLine Quote: > > > > strFile.Close > > > > strCommand.Close > > > > strLog.close Quote: > > > > Set oExec = oWsc.Exec("D:\BatchJobs\WebSiteSync\Sync.bat") > > > > Do While oExec.Status <> 1 > > > > WScript.Sleep 30000 > > > > Loop Quote: > > > > set strLog = fso.openTextFile("D:\BatchJobs\WebSiteSync\msdeploysync.log", > > > > ForAppending) > > > > strLog.WriteLine "Finished at " & Date() & " " & Time() > > > > strLog.close Quote: > > > The Exec method is not suitable when you need to wait until a shell command > > > has completed its operation. Use the Run method instead - it accepts an > > > optional parameter bWaitOnReturn. > Dan, > > First, you need to define the value of bWaitOnReturn: True means wait > and false (default) means don't wait. Commonly this is done with a > literal, rather than a variable (unless it is programatically > important to be a variable). So, you probably want ... > > Set WshShell = WScript.CreateObject("WScript.Shell") > WshShell.Run "D:\BatchJobs\WebSiteSync\Sync.bat",0,True > > However, the Exec.Status checks and looping you had in your original > script should have worked in fundamentally the same way. Therefore, I > must conclude that the underlying operations contained in your batch > procedures are the source of your problem. Since you didn't post > those, it's hard to be sure, but from your description, I can't > imagine anything else. Specifically, if an application invoked in one > or more of the batch files is a Win32 application or is launching an > additional thread and then terminating, the batch procedures would end > and return control to your script, even while the application > continues to run. To get this behavior under control, a START > statement to launch the offending application(s) in the batch may be > all that is needed. However, it might be harder than that. > > I think some insight into the batch procedures may be needed to solve > your problem. > > Tom Lavedas > *********** > http://there.is.no.more/tglbatch/ > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Zip error using VBSCRIPT Error:Object not a collection | VB Script | |||
| error CDO.Message - VBScript | VB Script | |||
| How to remove vbscript text from message box | VB Script | |||
| Cannot uninstall iTunes: VBscript message | Software | |||
| Bitlocker halts boot up with error that winload.exe has been chang | Vista General | |||