Click here to return to the KiXtart HelpDesk main page...

KiXtart Script Depot

Send NET messages to user based on global groups

 ;
 ; SCRIPT :  NETSEND.KIX
 ; DATE :     10.05.1999
 ; AUTHOR : Morten Lunde
 ; E-MAIL :   morten.lunde@observer.no
 ;
 ; PURPOSE: Send NET messages to user based on global groups
 ;
 ; INFO : Requires external program GLOBAL.EXE from NT Resource Kit Tools.
 ; GLOBAL.EXE must be in path (or you have to change the $cmd line)
 ; Creates a file in your temp directory and deletes it when finnished.
 ; Change the domain variable to whatever you need.
 ;
 ; BATFILE: This is the batchfile used to run this script:
 ; @kix32 {path_to_script}\netsend.kix $g=%1 $t=%2
 ;
 ; USAGE : netsend groupname "Text to send to group" {enter}
 ; or
 ; netsend {enter} (then asks for group and text)
 ;
 ; INPUT :
 ; $g = Name of group to send to
 ; $t = Text message to send
 ;
 ; HISTORY:
 ; 10.05: Changed command to use START /B for faster timeout on non-active users
 ; 23.04: Initial version
 ;
 ; All suggestions are welcome!
 ;

 $cr = chr(13) + chr(10)
 $tmpfile = "%temp%\grpmbmr.txt"
 $domain = "OBSOSL"

 IF $g = ""
   "Please enter group name ([enter] to abort): $cr"
   GETS $g
 ENDIF

 IF LEN($g) = 0
   GOTO end
 ENDIF

 $i = 0
 $found = 0

 DO
   $gr = ENUMGROUP($i)
   $i = $i + 1
   IF LCASE($g) = LCASE($gr)
     $found = 1
   ENDIF
 UNTIL LEN($gr) = 0 OR $found = 1

 IF $found = 0
   "No such group ($g)! $cr"
   GOTO end
 ENDIF

 IF $t = ""
   "Please enter message to send ([enter] to abort): $cr"
   GETS $t
 ENDIF

 IF LEN($t) = 0
   "No message entered, aborting. $cr"
   GOTO end
 ENDIF

 $cmd = "%comspec% /C GLOBAL $g $domain >$tmpfile"
 SHELL $cmd
 $foo = open(1,"$tmpfile",2)
 DO
   $user = readline(1)
   IF LEN($user) <> 0
     $cmd = '%comspec% /C START /B NET SEND $user "$t"'
     SHELL $cmd
   ENDIF
 UNTIL LEN($user) = 0
 $foo = CLOSE(1)

 :end
 DEL $tmpfile