运行以下 vbscript 调用 svnadmin 转储失败(即没有创建转储)
Set objShell = CreateObject("WScript.Shell")
Set objShellExec = objShell.Exec("svnadmin dump C:\svn_repos > C:\fullbackup")
我从另一篇文章中发现,svn dump 使用 WScript.Shell 失败,我必须使用 cmd 创建一个新的命令解释器,如下所示:
Set objShellExec = objShell.Exec("%comspec% /c" & "svnadmin dump C:\svn_repos > C:\fullbackup")
这成功创建了转储,但我永远无法读取输出信息(即 * 转储修订版 100。* 转储修订版 101 等)。我试过了
Do While objWshScriptExec.Status = 0
Wscript.Echo objShellExec.StdOut.Readline
Wscript.Echo objShellExec.StdErr.Readline
WScript.Sleep 100
Loop
但什么都没有显示。
我可以知道如何读取输出信息,以及为什么我需要在 svnadmin dump 命令正确执行之前使用“%comspec% /c”创建一个新的命令解释器?谢谢。
问候,德克斯顿
编辑代码:
Set objShell = CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strOutput = "c:\svn_backup\fullbackupa"
Set objOutFile = objFS.CreateTextFile(strOutput,True)
Set objShellExec = objShell.Exec("%comspec% /c " & "svnadmin dump C:\svn_repos")
Do While objShellExec.Status = 0
stdoutline=objShellExec.StdOut.Readline
'Wscript.Echo stdoutline 'echo to standard output
Wscript.Echo objShellExec.StdErr.Readline
objOutFile.WriteLine(stdoutline & vbCrLf) 'write to file at the same time
WScript.Sleep 100
Loop
objOutFile.Close
解决方案:
Set objShell = CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strOutput = "c:\svn_backup\fullbackupa"
Set objOutFile = objFS.CreateTextFile(strOutput,True)
Set objShellExec = objShell.Exec("%comspec% /c " & "svnadmin dump C:\svn_repos > c:\svn_backup\fullbackupb")
Do While objShellExec.Status = 0
stdoutline=objShellExec.StdErr.Readline
Wscript.Echo stdoutline 'echo to standard output
'Wscript.Echo objShellExec.StdErr.Readline
objOutFile.WriteLine(stdoutline & vbCrLf) 'write to file at the same time
WScript.Sleep 100
Loop
objOutFile.Close