VBScript让幻影进程运行; 如何摆脱他们?

我正在做一些自动化与VBScript,每次我运行脚本,它离开了进程“EXCEL.EXE”运行。 我如何防止?

码:

Set oFs = CreateObject("Scripting.FileSystemObject") set objExcel = createObject("Excel.Application") set objWorkbook = objExcel.Workbooks.open("C:\test\test.xlsx") for each sheet in objWorkbook.worksheets wscript.echo(sheet.name) set objSheet = sheet next set objSheet = Nothing set objworkbook = Nothing set objExcel = Nothing Set oFs = Nothing 

我的脚本退出后,如何防止EXCEL.exe继续运行?

使用这个来closuresExcel。 在Next之后用下面的代码replace你的代码。

 set objSheet = Nothing 'Tells workbook to close without saving changes. objWorkbook.Close false set objworkbook = Nothing 'Tells Excel Application to quit. objExcel.Quit set objExcel = Nothing Set oFs = Nothing