Solved

using netsend from windows app

Posted on 2003-11-19
7
535 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
itextsharp with c# 3 35
parse string in c# 5 41
ASP.NET data base connection 35 95
async questions 5 49
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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