刚才实现了chm的生成代码,这回不用调用命令行了,直接在vbs的内部就可以完成.
vbs的wshshell提供了一个wshscriptexec对象:
http://www.elook.net.cn/handbook/windowsscript/html/wslrfscriptexecobject.htm
这个对象是通过wshell.exec得到的,以下是我实现的部分代码:
' 调用'hhc.exe'生成chm并保存输出到log文件
Sub GenChm()
Dim stream
Set stream = fso.opentextfile(logfile,2,true)
Dim oexec
Set oexec = shell.Exec(cmdline)
Do While Not oExec.StdOut.AtEndOfStream
Dim line
line = oexec.stdout.readline()
Call wscript.stdout.writeline(line)
Call stream.writeline(line)
Loop
Call stream.close
End Sub
当然,为了让wscript的标准输入输出句柄有效,必须使用cscript宿主来运行:-)
Last edited by sonicandy on 2008-11-29 at 23:21 ]