Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 541
  • Last Modified:

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
0
andrew67
Asked:
andrew67
  • 3
  • 2
  • 2
1 Solution
 
tgannettsCommented:
Have a look at the following:

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

Hope this helps.

Tom
0
 
andrew67Author Commented:
thanks but its a bit longwinded having to write to a .bat file first any more clues
0
 
tgannettsCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
_TAD_Commented:



            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
 
_TAD_Commented:
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
 
_TAD_Commented:

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
 
andrew67Author Commented:
thanks thats great got it working a treat
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now