[Help] Joke with cmd from network

Maxime -  
 Maxime -
Hello everyone (yes, there are quite a few qualified young ladies in IT ;) )

So in class, we use the command line of our virtual machines that are networked to chat, and I created a small .bat software that allows me to chat with my friends
and I got the idea to "troll" them with a loop of messages where I choose the number at the start!
But I've run into various problems, first of all, the if statements are very restrictive and if I understood correctly, it only accepts one command at a time. Then I found a technique online which is the if [command] Goto X that apparently works, but my software crashes and I can't find the solution! Here is the script:

@echo off :A Cls set c=0 set e=1 echo ************************** echo * * echo * MESSENGER * echo * * echo ************************** echo "Do you want a Trolling message" Set /p r=response: if %r%==yes Goto B if %r%==no Goto C :B set /p i=Number_of_sends: set /p n=User: set /p m=Message: :D net send %n% %m% %c%==%c%+%e% if %i%<%c% Goto D if %i%==%c% Goto A :C set /p n=User: set /p m=Message: net send %n% %m% pause Goto A


Configuration: Windows XP / Firefox 16.0

2 answers

  1. Maxime
     
    I tested a new syntax, but still no result!

    echo "Do you want a Trolling message" Set /p r=response: if %r%==yes Goto B if %r%==no Goto C :B set /a i=Num_sends: set /p n=User: set /p m=Message: :E net send %n% %m% Goto D :C set /p n=User: set /p m=Message: net send %n% %m% pause Goto A :D set loop=%loop%+%e% if (%loop%<%i%)(Goto E) else (pause) Goto A
    3
  2. totof31 Posted messages 165 Status Member 74
     
    Hi
    When you say the software crashes, what are the symptoms?

    It seems to me that to test strings you have to do:
    IF %var% EQU "string"
    1
    1. totof31 Posted messages 165 Status Member 74
       
      set boucle=%boucle%+%e%
      ==> set /a boucle=%boucle%+%e%
      0
    2. Maxime
       
      the software crashes, meaning it sends the message once to the concerned person and then the command closes automatically. I also think the problem comes from the loop, but I don't see why! :/
      0
    3. totof31 Posted messages 165 Status Member 74
       
      Have you tried the set /a loop...?
      Otherwise, put some echo hello1,2,3... and echo %var% to see where you are going and the values of your loop variables...
      0
    4. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 660
       
      and also
      if %loop% LSS %i% (Goto E) else (pause)
      0
    5. Maxime
       
      Yes, I tried the set /a but it doesn't work, the message sends fine once but then the cmd closes!
      Thanks Dubeck, apparently your solution works, here is my final code:

      @echo off :A Cls set /a boucle=0 set /a e=1 echo ************************** echo * * echo * MESSENGER * echo * * echo ************************** echo "Do you want a Trolling message" Set /p r=response o/n: if %r%==o Goto B if %r%==n Goto C :B set /p i=Number_of_sends: set /p n=User: set /p m=Message: :E net send %n% %m% Goto D :C set /p n=User: set /p m=Message: net send %n% %m% pause Goto A :D set /a boucle=%boucle%+%e% if %boucle% LSS %i% (Goto E) else (pause) Goto A
      1