you already seem to have correct start there...
just the same as you do your dir, you probably can do the redirect:

$RunGrpProgram = "g:\groups\usrtogrp.exe " + $selecttextfile2
shell "%comspec% /c $RunGrpProgram > %%temp%%\mytempfile.txt"

$nul=open(2,"%temp%\mytempfile.txt")
$line=readline(2)
while not @error
if instr($line, "success")
"this thing worked fine"
endif
$line=readline(2)
loop
$nul=close(2)

or something similar...
looking at the code, I suggest you read this thread:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=81592
_________________________
!

download KiXnet