Solved

using netsend from windows app

Posted on 2003-11-19
7
530 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XML to SQL Table using c# 5 46
Exception in Log4Net 1 19
Handle null when using linq in this line 1 20
Events in static methods 3 25
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now