What's wrong with my Batch Script?

Discussion in 'Computer Software and Operating Systems' started by Asia81, May 29, 2016.

  1. Asia81
    OP

    Asia81 In my Ecchi World <3

    Member
    12
    Nov 15, 2014
    France
    Albi
    Hi guys, here is my batch script :

    Code:
    @echo off
    echo.
    set /p S0=Y or N :
    if /i %S0%==Y (SET %S1%=xutf) ELSE (SET %S1%=xtf)
    3dstool.exe -%S1% exefs DecryptedExeFS.bin --exefs-dir ExtractedExeFS --header HeaderExeFS.bin
    pause
    
    Let's explain.

    I the user anwser y, %S1% in the 3dstool line should be replaced with -xutf, if the user anwser n, %S1% should be replaced with -xtf.

    But it's not working, no matter what I try, so where I'm wrong?
     
    Last edited by Asia81, May 29, 2016
  2. Zan'

    Zan' 2F88744FEED717856386400A44BBA4B9CA62E76A32C715D4F

    Member
    2
    Oct 8, 2015
    First of all I would suggest you start using quotation marks to prevent crashes.
    And you can't set a variable like
    %var%=X if it should be var=X
    (Note: this can be used for pointers and similar things.)

    Your fix would be looking like this
    Code:
    @echo off
    echo.
    set /p S0="Y or N : "
    if /i "%S0%"=="Y" (SET S1=xutf) ELSE (SET S1=xtf)
    3dstool.exe -%S1% exefs DecryptedExeFS.bin --exefs-dir ExtractedExeFS --header HeaderExeFS.bin
    pause
    
    However I would suggest you use CHOICE instead. Which would give you something like this:
    Code:
    @echo off
    CHOICE /M "Do you want to decompress Code.bin? "
    if "%errorlevel%"=="1" (SET par=xutf) ELSE (SET par=xtf)
    3dstool.exe -%par% exefs DecryptedExeFS.bin --exefs-dir ExtractedExeFS --header HeaderExeFS.bin
    pause
    
     
    Last edited by Zan', May 29, 2016
    Asia81 likes this.
  3. Asia81
    OP

    Asia81 In my Ecchi World <3

    Member
    12
    Nov 15, 2014
    France
    Albi
    Thanks a Lot!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice