your second post was kinda confusing, but your first post gives the rules...

so, you can use the good old open(), writeline(), close() method.
it can be too taxing on the coding so there are couple shorthands, like redirectoutput()

then you can always use the lazy way:
shell "%comspec /c echo "+@wksta+" >> path_to_that_file_dude.txt"
_________________________
!

download KiXnet