Skip navigation

JSI Tip 1024. NET SEND a text file.


If have scripted sndfle.bat to allow you to NET SEND the contents of a text file to users. The syntax is:

sndfle filename \[User1 | /DOMAIN\] \[User2 User3 ... UserN\]

where:

Filename is the name of the text file, either single or multi-line, that contains the message text.

Userx is a list of usernames, separated by a space, who should receive the message. You may use /DOMAIN, instead of any usernames, to send to all users in the domain.

Note: The longest message I was able to send was 887 character to users and 127 characters to /DOMAIN.

sndfle.bat contains:


@echo off
setlocal
if \{%2\}

\{\} (echo usage: sndfle msgfile user-list) & (goto end) if not exist %1 (echo usage: sndfle msgfile user-list) & (goto end) for /f "Tokens=*" %%i in ('type %1') do call :setmsg ##"%%i"## set msg=%msg:##"=% set msg=%msg:"##=% :LOOP if \{%2\}

\{\} endlocal&goto end net send %2 %msg% shift /2 goto :LOOP :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