using netsend from windows app

im trying to write a windows app in c# that will then send a netsend message

any clues greatly appreciated
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Have a look at the following:

Hope this helps.

andrew67Author Commented:
thanks but its a bit longwinded having to write to a .bat file first any more clues
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

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

Hope this is of more use to you.

Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.


            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);
                  string dosOut = DOS.StandardOutput.ReadToEnd();



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

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);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andrew67Author Commented:
thanks thats great got it working a treat
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.