Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Net Send Emulator

Net Send Emulator

Scheduled Pinned Locked Moved C#
help
13 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O obelisk29

    Hi I'm building a program that executes net send commands for lan use. An I was wondering howto format the message so it comes out multiline. If you have any ideas on howto do this please help btw I've already tried \n and \r\n Help is greatly appreciated

    A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #2

    I think its something like system.environment.newline

    O 1 Reply Last reply
    0
    • A Anonymous

      I think its something like system.environment.newline

      O Offline
      O Offline
      obelisk29
      wrote on last edited by
      #3

      Ok maybe I should rephrase my question I am not using .NET to directly send the messages I am building a .bat file then executing it. SO what would the DOS cmd for doing multiline net send commands be. Help is greatly appreciated

      H 1 Reply Last reply
      0
      • O obelisk29

        Hi I'm building a program that executes net send commands for lan use. An I was wondering howto format the message so it comes out multiline. If you have any ideas on howto do this please help btw I've already tried \n and \r\n Help is greatly appreciated

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #4

        You should use either Environment.NewLine or use a a string literal (beings with "@" where new lines and tabs are part of the string until closed):

        using System;
        using System.Diagnostics;

        public class MsgTest
        {
        public static void Main()
        {
        string example = @"This is a test
        on a new line.";
        ProcessStartInfo psi = new ProcessStartInfo("net.exe",
        string.Concat("send ppheath ", example));
        Process.Start(psi);
        }
        }

        You could also P/Invoke the NetMessageBufferSend function. You can read more about it in the Platform SDK (Network Management, or on MSDN). It isn't hard to invoke and is pretty easy to use. Read the messaging overview link for it, though.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        O 2 Replies Last reply
        0
        • H Heath Stewart

          You should use either Environment.NewLine or use a a string literal (beings with "@" where new lines and tabs are part of the string until closed):

          using System;
          using System.Diagnostics;

          public class MsgTest
          {
          public static void Main()
          {
          string example = @"This is a test
          on a new line.";
          ProcessStartInfo psi = new ProcessStartInfo("net.exe",
          string.Concat("send ppheath ", example));
          Process.Start(psi);
          }
          }

          You could also P/Invoke the NetMessageBufferSend function. You can read more about it in the Platform SDK (Network Management, or on MSDN). It isn't hard to invoke and is pretty easy to use. Read the messaging overview link for it, though.

          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

          O Offline
          O Offline
          obelisk29
          wrote on last edited by
          #5

          Thanks so much for helpful and articulate response I will try that. =)

          1 Reply Last reply
          0
          • O obelisk29

            Ok maybe I should rephrase my question I am not using .NET to directly send the messages I am building a .bat file then executing it. SO what would the DOS cmd for doing multiline net send commands be. Help is greatly appreciated

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #6

            Then why did you post the C# forum?! What are we supposed to think? Escaping characters in batch files isn't supported, nor are new lines.

            -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

            O 1 Reply Last reply
            0
            • H Heath Stewart

              Then why did you post the C# forum?! What are we supposed to think? Escaping characters in batch files isn't supported, nor are new lines.

              -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

              O Offline
              O Offline
              obelisk29
              wrote on last edited by
              #7

              Because I am creating the batch file using .NET and I wasn't sure if .NET does some wierd formatting.

              D 1 Reply Last reply
              0
              • H Heath Stewart

                You should use either Environment.NewLine or use a a string literal (beings with "@" where new lines and tabs are part of the string until closed):

                using System;
                using System.Diagnostics;

                public class MsgTest
                {
                public static void Main()
                {
                string example = @"This is a test
                on a new line.";
                ProcessStartInfo psi = new ProcessStartInfo("net.exe",
                string.Concat("send ppheath ", example));
                Process.Start(psi);
                }
                }

                You could also P/Invoke the NetMessageBufferSend function. You can read more about it in the Platform SDK (Network Management, or on MSDN). It isn't hard to invoke and is pretty easy to use. Read the messaging overview link for it, though.

                -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                O Offline
                O Offline
                obelisk29
                wrote on last edited by
                #8

                That works but only for one person... But whenever I send it to multiple users via the PIPE "|" symbol it doesn't compute the the rest of the commands because they are put on as arguments. But when I do the batch file it doesn't do the multiline messaging so I'm stumped. Please Help

                H 1 Reply Last reply
                0
                • O obelisk29

                  That works but only for one person... But whenever I send it to multiple users via the PIPE "|" symbol it doesn't compute the the rest of the commands because they are put on as arguments. But when I do the batch file it doesn't do the multiline messaging so I'm stumped. Please Help

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #9

                  This is just a problem of parsing command line arguments in your program. If you're sending to multiple people, then loop through the list of people and execute the command for each one.

                  -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                  O 1 Reply Last reply
                  0
                  • H Heath Stewart

                    This is just a problem of parsing command line arguments in your program. If you're sending to multiple people, then loop through the list of people and execute the command for each one.

                    -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                    O Offline
                    O Offline
                    obelisk29
                    wrote on last edited by
                    #10

                    When I first built my program I did that. But it takes FOREVER. So then I thought maybe I could distribute each person into a thread.. but that would be too hectic. So I don't know what else to do? BTW Thx for putting up with me ;)

                    H 1 Reply Last reply
                    0
                    • O obelisk29

                      When I first built my program I did that. But it takes FOREVER. So then I thought maybe I could distribute each person into a thread.. but that would be too hectic. So I don't know what else to do? BTW Thx for putting up with me ;)

                      H Offline
                      H Offline
                      Heath Stewart
                      wrote on last edited by
                      #11

                      Just thread it. "net send" takes two or more parameters (besides switches) a single user or computername and the rest of the parameters are the message. There's no way around it. Just use a worker thread (see the ThreadPool class), passing the user/computer name as the state variable and save the message to a member field. The thread execution method gets the username and gets the value from the message field and sends the message with "net send".

                      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                      1 Reply Last reply
                      0
                      • O obelisk29

                        Because I am creating the batch file using .NET and I wasn't sure if .NET does some wierd formatting.

                        D Offline
                        D Offline
                        Daniel M Edwards
                        wrote on last edited by
                        #12

                        What exactly is a .NET batch file?

                        1 Reply Last reply
                        0
                        • O obelisk29

                          Hi I'm building a program that executes net send commands for lan use. An I was wondering howto format the message so it comes out multiline. If you have any ideas on howto do this please help btw I've already tried \n and \r\n Help is greatly appreciated

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #13

                          I think that it is good try to use the following API : NET_API_STATUS NetMessageBufferSend( LPCWSTR servername, LPCWSTR msgname, LPCWSTR fromname, LPBYTE buf, DWORD buflen ); try to import it to you class and use it , and i think that now you can send escap characters like /n /r ..... Mhmoud Rawas ------------ Software Eng.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups