anton zamov it expert logo    

home page latest news web development curriculum vitae scripts contact me

  • C# (Microsoft .NET)
  • JAVA
  • Dynamic HTML
  • PHP & MySQL
  • ASP.NET - C# & VB.NET
  • Perl & CGI
  • C | C++
  • Vector Markup Language
  • SMIL
  • Assembler
  • Databases
  • Wap Development
  • Web site promotion
  • Web Marketing



How to send \" NET SEND \" messages ( Windows 2000 & Windows XP only )?

(C# free example written by Anton Zamov.)


How to send " NET SEND " messages ( Windows 2000 & Windows XP only )?

Have you ever send messages to the local network using the command promt and the well known command "net send"?.<br>
The 2 methods listed below allows you to make exactly the same thing from your C# application.


protected string name="";
protected string sysname="";

public void NetSend(string mname,string strMessage)
{
/*
This method is created by Anton Zamov.
web site: http://zamov.online.fr

Feel free to use and redistribute this method
in condition that you keep this message intact.
*/
                  this.sysname=mname;
                  this.strMessage = strMessage;
                  ThreadStart tStart = new ThreadStart(this.SendMessageThread);
                  Thread senderThread = new Thread(tStart);
                  senderThread.Start();
}


public void SendMessageThread()
{
/*
This method is created by Anton Zamov.
web site: http://zamov.online.fr

Feel free to use and redistribute this method
in condition that you keep this message intact.
*/
                  try
                  {


                        string strLine = "net send " + sysname + " " +
                              this.strMessage + " > C:netsend.log";
                        FileStream fs =       new FileStream("c:netsend.bat" ,
                              FileMode.Create,
                              FileAccess.Write);
                        StreamWriter streamWriter = new StreamWriter(fs);
                        streamWriter.BaseStream.Seek(0, SeekOrigin.End);
                        streamWriter.Write(strLine);
                        streamWriter.Flush();
                        streamWriter.Close();
                        fs.Close();

                        Process p = new Process();
                        p.StartInfo.FileName = "C:netsend.bat";
                        p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                        p.Start();
                        p.WaitForExit();
                        p.Close();

                        FileStream fsOutput = new FileStream("C:netsend.log",
                              FileMode.Open ,
                              FileAccess.Read);
                        StreamReader reader = new StreamReader(fsOutput);
                        reader.BaseStream.Seek(0,SeekOrigin.Begin);
                        string strOut = reader.ReadLine();
                        reader.Close();
                        fsOutput.Close();


                  }
                  catch(Exception)
                  {

                        // TODO

                  }

}









Jobs Portal, poweful jobs board software

PHP Mall, multi vendors mall website software

Car Portal, php script for auto classifieds websites

NetArt Media, software products and services

Real Estate Portal, web software for real estate portals

Blog System, multi user blog hosting script

PHP Store, powerful e-commerce system written in PHP


C# (Microsoft .NET) | JAVA | Dynamic HTML | PHP & MySQL | Perl & CGI | C | C++ | Vector Markup Language
SMIL | Assembler | Databases | Wap Development | Web site promotion | Web Marketing

Copyright © Anton Zamov 1998 - 2023