JSI Tip 4368. How do I 'net send' the contents of a text file to the users defined in 'group' file?


In tips 0660, 0757, 1024, and 1025, I scripted various version of 'net send'.

If you wish to net send the contents of a text file to a group of user that is defined in a text file, use:

sndfleuf msgfile userfile

where:

msgfile   is a file that contains the message. If you type multiple lines, one long line will be sent.

userfile is a text file that contains one user per line.

Example: c:\folder1\message.txt contains:

Line 1
line 2
line 3

C:\folder2\myteam.txt contains:
Jerry
Jennifer
Graystone

sndfleuf "c:\folder1\message.txt" "c:\folder2\myteam.txt"
will send 

Line 1
line 2 
line 3

to Jerry, Jennifer, and Graystone.
sndfleuf.bat contains:
@echo off
setlocal
if \{%2\}==\{\} (echo usage: sndfleuf msgfile userfile) & (goto :EOF)
if not exist %1 (echo usage: sndfleuf msgfile userfile) & (goto :EOF)
if not exist %2 (echo usage: sndfleuf msgfile userfile) & (goto :EOF)
set msgfile=%1
set userfile=%2
for /f "Tokens=*" %%i in ('type %msgfile%') do call :setmsg ##"%%i"##
set msg=%msg:##"=%
set msg=%msg:"##=%
for /f "Tokens=*" %%u in ('type %userfile%') do net send "%%u" %msg%
endlocal
goto :EOF
:setmsg
if not defined msg set msg=%1&goto end
set msg=%msg%%1
:end


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish