• Welcome, Guest. Please login.
 
February 21, 2020, 08:08:18 am

News:

Welcome to the SQLitening support forums!


Message to any computers on local network (source code)

Started by cj, January 04, 2020, 10:55:09 am

Previous topic - Next topic

cj

[source]
#INCLUDE "sqlitening.inc"
'Requires Windows 10 Pro

FUNCTION PBMAIN () AS LONG 'NetSend.bas

 LOCAL sUsers,sFile,sData,sMsg AS STRING

 sFile  = "test123.dat"             'must be in FACT or error -9
 sData  = "some data"               'second parameter of slPut

 sUsers = "127.0.0.1"               'receivers of shell(msg.exe)
 slPutFile sFile,sData,"E0"         'slPut using SQLitening
 sMsg   =  sFile + $CR + slGetError 'message for receivers

 NetSendMessage sUsers,sMsg,0       '0=don't timeout on receiver screens

END FUNCTION

SUB NetSendMessage(sComputers AS STRING,BYVAL sMsg AS STRING, SecondsOnScreen AS LONG)
 LOCAL sShell AS STRING
 IF INSTR("-/",LEFT$(TRIM$(sMsg),1)) THEN
  sMsg = WRAP$(sMsg,"[","]") 'TRIM of sMsg started  "-" or "/" or is empty
 END IF

 'Messages are independent of programs
 'They are placed in a queue and only 1 is displayed on receiving computer
 'If Time: (SecondsOnScreen=0) received must click to clear the message off the screen
 'Sending message to all sessions using the "*" may be needed so it automatically insert
 'If first character of message is "/" or "-"  or "" the message wouldn't send, now wrapped within $DQ

 LOCAL x,pid AS LONG
 FOR x = 1 TO PARSECOUNT(sComputers) 'ComputerName, IPAddress, ...
  'put into a string for your testing
  sShell = "msg.exe /server:"+ TRIM$(PARSE$(sComputers,x)) + " * /time:" + FORMAT$(SecondsOnScreen) + " " + sMsg
  'MSGBOX sShell
  pid = SHELL(sShell,0)
 NEXT
END SUB
#IF 0
SEND a message TO a user.

MSG {username | sessionname | sessionid | @filename | *}
    [/SERVER:servername] [/TIME:seconds] [/V] [/W] [message]

  username            Identifies the specified username.
  sessionname         The NAME OF the session.
  sessionid           The ID OF the session.
  @filename           Identifies a file containing a list OF usernames,
                      sessionnames, AND sessionids TO SEND the message to.
  *                   SEND message TO ALL sessions ON specified server.
  /SERVER:servername  SERVER TO contact (DEFAULT IS current).
  /TIME:seconds       Time delay TO wait FOR receiver TO acknowledge msg.
  /V                  DISPLAY information about actions being performed.
  /W                  Wait FOR response FROM USER, useful WITH /V.
  message             Message TO send.  IF NONE specified, prompts FOR it
                      OR reads FROM stdin.
#ENDIF