Solved

using netsend from windows app

Posted on 2003-11-19
7
536 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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