Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch serial system, errors.  (Read 7989 times)

0 Members and 1 Guest are viewing this topic.

whitekidney

    Topic Starter


    Rookie

    Batch serial system, errors.
    « on: January 16, 2009, 12:21:19 AM »
    Howdy, i started with batch coding yesterday, and now im trying to make a serial code protection for my bat file.

    Okay, the script is as following :

    Quote from: main.txt
    SET /P serial= Enter your SERIAL CODE here:
     if "%serial%"=="3612-3472-631" goto abcd
    :abcd
    echo SET /p %serial%=%serial% >> cache.bat
    echo SET /p %name%=%name% >> cache.bat
    pause
    But whenever im trying to call the cache file, it wont set %serial% to the serial key provided, it will just echo the serial and exit.
    Any solution ?

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Batch serial system, errors.
    « Reply #1 on: January 16, 2009, 12:37:08 AM »
    im trying to make a serial code protection for my bat file.

    that is one of the most pointless things I've ever heard. it's like putting a serial number in a text file, and at the top saying, "if your serial code isn't one of the following, your not allowed to read this".


    In any case- why exactly do you want to place it in a second batch file anyway?


    I was trying to dereference Null Pointers before it was cool.

    Dias de verano

    • Guest
    Re: Batch serial system, errors.
    « Reply #2 on: January 16, 2009, 12:39:08 AM »
    This is what happens when I run that code
    Code: [Select]
    S:\Test\Batch\After 08-01-09\Tryout>tryme.bat

    S:\>SET /P serial= Enter your SERIAL CODE here:
     Enter your SERIAL CODE here:qwerty

    S:\>if "qwerty" == "3612-3472-631" goto abcd

    S:\>echo SET /p qwerty=qwerty  1>>cache.bat

    S:\>echo SET /p =  1>>cache.bat

    S:\>pause
    Press any key to continue . . .


    And this is what cache.bat looks like

    Code: [Select]
    SET /p qwerty=qwerty
    SET /p =

    1. If you have a line

    @echo off

     at the start, it won't echo each line.

    2. You have an IF test in the second line and if the test is passed (if what is entered by the user matches the password) then you go to label :abcd. But, the way IF works is that if the test is failed, you just go to the next line, which is the label :abcd! So you're going to go there anyway whatever the user inputs.

    3. Why are you echoing this to cache.bat?

    Code: [Select]
    SET /p %serial%=%serial%



    whitekidney

      Topic Starter


      Rookie

      Re: Batch serial system, errors.
      « Reply #3 on: January 16, 2009, 12:39:59 AM »
      Urr, well, im not sure how to put it in the main file.

      This is my whole script.

      Quote from: main
      SET /P name= Enter your NAME here:
      SET /P serial= Enter your SERIAL CODE here:
       if "%serial%"=="3612-3472-631" goto abcd
      :abcd
      echo SET /p %serial%=%serial% >> cache.bat
      echo SET /p %name%=%name% >> cache.bat
      :load
      if exist cache.bat goto val
      goto serial
      :val
      start cache.bat
      goto :serial2
      :serial2
       if "%serial2%"=="3612-3472-631" goto credits
      Help would be appreciated


      edit : I forgot the echo off, anyways.
      I want it to be
       "set /p serial=serial code here
         set /p name=name here"

      But it wont work.

      whitekidney

        Topic Starter


        Rookie

        Re: Batch serial system, errors.
        « Reply #4 on: January 16, 2009, 12:45:10 AM »
        Urr, well, im not sure how to put it in the main file.

        This is my whole script.

        Quote from: main
        SET /P name= Enter your NAME here:
        SET /P serial= Enter your SERIAL CODE here:
         if "%serial%"=="3612-3472-631" goto abcd
        :abcd
        echo SET /p %serial%=%serial% >> cache.bat
        echo SET /p %name%=%name% >> cache.bat
        :load
        if exist cache.bat goto val
        goto serial
        :val
        start cache.bat
        goto :serial2
        :serial2
         if "%serial2%"=="3612-3472-631" goto credits
        Help would be appreciated


        edit : I forgot the echo off, anyways.
        I want it to be
         "set /p serial=serial code here
           set /p name=name here"

        But it wont work.
        Quote
        2. You have an IF test in the second line and if the test is passed (if what is entered by the user matches the password) then you go to label :abcd. But, the way IF works is that if the test is failed, you just go to the next line, which is the label :abcd! So you're going to go there anyway whatever the user inputs.

        Yes, they will go to abcd anyways, but when they run the program it wont open because %serial% isnt the number that i want it to be (but i cant make it work)
        edit:
        darnit, it seems like i double posted.

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: Batch serial system, errors.
        « Reply #5 on: January 16, 2009, 12:48:45 AM »
        ok. look at this, and let's think for a sec.

        Code: [Select]
        echo SET /p %serial%=%serial% >> cache.bat

        What does the computer do? if you echoed %serial%, it would display the VALUE of serial. Why would echoing to a file give you a different result?


        In short- you need to escape the percent signs.
        Code: [Select]
        echo SET /p ^%serial^%=Serial: >> cache.bat

        echo SET /p ^%name^%=Name: >> cache.bat

        I was trying to dereference Null Pointers before it was cool.

        whitekidney

          Topic Starter


          Rookie

          Re: Batch serial system, errors.
          « Reply #6 on: January 16, 2009, 12:51:58 AM »
          ok. look at this, and let's think for a sec.

          Code: [Select]
          echo SET /p %serial%=%serial% >> cache.bat

          What does the computer do? if you echoed %serial%, it would display the VALUE of serial. Why would echoing to a file give you a different result?


          In short- you need to escape the percent signs.
          Code: [Select]
          echo SET /p ^%serial^%=Serial: >> cache.bat

          echo SET /p ^%name^%=Name: >> cache.bat


          I tried this code, didnt work. (or i might just be stupid)

          What im trying to do is :
          I make the user enter name and serial, then it is stored to a .bat file (or .txt file or whatever) so they wont have to re-input the serial and name next time they start the program.

          Your code just asked me for the serial and name again.

          Seems like i explained my problem wrong, sorry.

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: Batch serial system, errors.
          « Reply #7 on: January 16, 2009, 12:58:38 AM »
          you were echoing the CODE to the file.

          if you just want to save the serial and name:

          Code: [Select]
          set /p %serial%=serial:
          set /p %name%=name:
          echo %serial%> key.bin
          echo %name%>> key.bin


          reading them back in, however, will be a different matter altogether.

          What exactly will the serial be protecting, anyway?
          I was trying to dereference Null Pointers before it was cool.

          Dias de verano

          • Guest
          Re: Batch serial system, errors.
          « Reply #8 on: January 16, 2009, 12:59:02 AM »
          In short- you need to escape the percent signs.

          Surely you need to double them up?

          whitekidney

            Topic Starter


            Rookie

            Re: Batch serial system, errors.
            « Reply #9 on: January 16, 2009, 01:01:00 AM »
            you were echoing the CODE to the file.

            if you just want to save the serial and name:

            Code: [Select]
            set /p %serial%=serial:
            set /p %name%=name:
            echo %serial%> key.bin
            echo %name%>> key.bin


            reading them back in, however, will be a different matter altogether.

            What exactly will the serial be protecting, anyway?
            Just a little tool that i made, i wanted to make this serial system to learn, not to really protect my file. :P
            Anyways, when ive echoed %serial% and %name% into the key.bin file, how am i going to load them back in ?

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: Batch serial system, errors.
            « Reply #10 on: January 16, 2009, 01:45:36 AM »
            In short- you need to escape the percent signs.

            Surely you need to double them up?


            depends how they want it stored.

            if we double it up- I imagine it would be stored in a variable that is the name of another variable... in this case something along the lines of storing the serial code under a variable of the persons name, which would work quite well.


            When ive echoed %serial% and %name% into the key.bin file, how am i going to load them back in ?


            that's an exercise for the reader :P

            I'm not so good when it comes to the new extended Syntax, but it would take a "FOR /F" of some description.
            I was trying to dereference Null Pointers before it was cool.

            whitekidney

              Topic Starter


              Rookie

              Re: Batch serial system, errors.
              « Reply #11 on: January 16, 2009, 06:43:11 AM »
              I need help lol, ive tried so many diffrent things.

              BatchRocks



                Hopeful
              • Thanked: 3
                Re: Batch serial system, errors.
                « Reply #12 on: January 16, 2009, 10:55:03 AM »
                Howdy, i started with batch coding yesterday, and now im trying to make a serial code protection for my bat file.

                Okay, the script is as following :

                Quote from: main.txt
                SET /P serial= Enter your SERIAL CODE here:
                 if "%serial%"=="3612-3472-631" goto abcd
                :abcd
                echo SET /p %serial%=%serial% >> cache.bat
                echo SET /p %name%=%name% >> cache.bat
                pause
                But whenever im trying to call the cache file, it wont set %serial% to the serial key provided, it will just echo the serial and exit.
                Any solution ?


                All they have to do is click EDIT then find the password. I see that you keep doing

                Code: [Select]
                set /p %serial%=%serial%
                I think of what you want to do is this:

                Code: [Select]
                set %serial%=%serial%
                because /p is user input. If you want to see the "serial" type in echo %serial%


                whitekidney

                  Topic Starter


                  Rookie

                  Re: Batch serial system, errors.
                  « Reply #13 on: January 16, 2009, 03:00:08 PM »
                  To make things better, im making it into a exe, aight, do you think im that stupid.

                  Still need help.

                  Dias de verano

                  • Guest
                  Re: Batch serial system, errors.
                  « Reply #14 on: January 16, 2009, 04:33:59 PM »
                  whitekidney, I think a big problem is going to be that you have a big project, but unfortunately you have very little idea of how to write batch scripts, and this is going to hold you back.

                  If you manage to make an .exe that does what you intend, I will be very surprised.