set swl = wscript.createobject("wbemscripting.swbemlocator") set s = swl.connectserver set rs = s.execquery("select * from win32_process where caption='cscript.exe' or caption='wscript.exe'") p = -1 for each r in rs if instr(1, r.commandline, scriptname) then wscript.echo r.caption p = r.parentprocessid end if next
set rs = s.execquery("select * from win32_process where processid=" & p) for each r in rs wscript.echo r.caption next