Solved

using netsend from windows app

Posted on 2003-11-19
7
534 Views
Last Modified: 2012-06-27
im trying to write a windows app in c# that will then send a netsend message

any clues greatly appreciated
0
Comment
Question by:andrew67
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Expert Comment

by:tgannetts
ID: 9778831
Have a look at the following:

http://zamov.online.fr/EXHTML/CSharp/CSharp_772553.html

Hope this helps.

Tom
0
 
LVL 3

Author Comment

by:andrew67
ID: 9778916
thanks but its a bit longwinded having to write to a .bat file first any more clues
0
 
LVL 5

Expert Comment

by:tgannetts
ID: 9779250
That's fair enough....

In that case, how about using the 'NetMessageBufferSend' function in the netapi32.dll.

I haven't actually used it in c#, but if you have a look at the following reference, it shows how it is used in vb.net:

http://beta.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20661984.html

It shouldn't be a problem converting the code to c#

Hope this is of more use to you.

Tom
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 22

Expert Comment

by:_TAD_
ID: 9781668



            private void DOSCommand()
            {            
                  Process DOS = null;
                  ProcessStartInfo qOptions = new ProcessStartInfo("cmd.exe", @"/C net send pc-02-49 This is a text Message");
                  qOptions.RedirectStandardOutput = true;
                  qOptions.UseShellExecute = false;
                  qOptions.WindowStyle = ProcessWindowStyle.Hidden;

                  DOS = Process.Start(qOptions);
                  DOS.WaitForExit();
                  
                  string dosOut = DOS.StandardOutput.ReadToEnd();

                  Console.Write(dosOut);
            }

0
 
LVL 22

Expert Comment

by:_TAD_
ID: 9781695
btw...

That uses the System.Diagnostics namespace


obviously you'll want to make a few changes like:


 ProcessStartInfo qOptions = new ProcessStartInfo("cmd.exe", @"/C net send " + strCompID + " " + strTextMessage);


where strCompID and strTextMessage are variables that you fill with pertinent data
0
 
LVL 22

Accepted Solution

by:
_TAD_ earned 125 total points
ID: 9781733

If you want your process to be completely "silent"  change the ShellExecute to True.

And if you don't care about logging who sent messages at a particular time, then you can set the redirect to false.


//Silent with no logging
      

                  Process DOS = null;
                  ProcessStartInfo qOptions = new ProcessStartInfo("cmd.exe", @"/C net send pc-02-49 This is a text Message");
                  qOptions.RedirectStandardOutput = false;
                  qOptions.UseShellExecute = true;
                  qOptions.WindowStyle = ProcessWindowStyle.Hidden;

                  DOS = Process.Start(qOptions);
                  DOS.WaitForExit();

0
 
LVL 3

Author Comment

by:andrew67
ID: 9785550
thanks thats great got it working a treat
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question