user3352738
user3352738

Reputation: 1

Why wont this simple batch script work?

Trying to make a simple switch BATCH for whether a .dll is used or not. Here is the code: It seems to do nothing but I can't find any errors. HELP?

:StartProgram
@echo off

set /p UsePowerup= Would you like to use power up plug in (1=Yes;2=No;3=Exit)?

If %UsePowerup%=3 
(
    EXIT
)
Else IF %UsePowerup%=2
(
    CD C:\Program Files (x86)\Steam\SteamApps\common\Fallout New Vegas\Data\NVSE\Plugins\

    If EXIST geckpu-nv-14.dll
    (
        ECHO "Moving Power Up Plugin to Desktop"
        MOVE geckpu-nv-14.dll C:\Users\Anonymous\Desktop\
        ECHO "Move Power Up Plugin to Desktop SUCCESS"
        PAUSE
        GOTO RunGECK
    )
    Else
    (
        ECHO "Plug-in not found! Try again."
        PAUSE
        GOTO StartProgram
    )
)
Else IF %UsePowerup%=1
(

    cd C:\Users\Anonymous\Desktop\
    If EXIST geckpu-nv-14.dll
    (
        ECHO "Moving Power Up Plugin to GECK"
        MOVE geckpu-nv-14.dll C:\Program Files (x86)\Steam\SteamApps\common\Fallout New Vegas\Data\NVSE\Plugins\
        ECHO "Move Power Up Plugin to Desktop SUCCESS"
        PAUSE
        GOTO RunGECK
    )
    Else
    ( 
        ECHO "Plug-in not found! Try again."
        PAUSE
        GOTO StartProgram
    )
)
Else ECHO "INVALID CHOICE Try Again"
(
    PAUSE
    CLS
    GOTO StartProgram
)


:RunGECK

cd C:\Program Files (x86)\Steam\SteamApps\common\Fallout New Vegas\
nvse_loader -editor
exit

Thanks guys

Upvotes: 0

Views: 270

Answers (1)

Matt Williamson
Matt Williamson

Reputation: 7095

Your parenthesis for your IF statements need to be on the same line. The same applies to the ELSE statements. You have to use == or EQU to do comparisons. You need to add /d to your CD commands to go directly to a path and your paths with spaces in them need to be quoted. You need to add exit /b or goto :eof at the end of your script before the functions, otherwise the function will always run with no parameters.

I think this should get you a lot closer.

@echo off
:StartProgram
set /p UsePowerup=Would you like to use power up plug in (1=Yes;2=No;3=Exit)? 

If %UsePowerup%==3 (
    EXIT
) Else (
    IF %UsePowerup%==2(
      CD /d "C:\Program Files (x86)\Steam\SteamApps\common\Fallout New Vegas\Data\NVSE\Plugins\"

        If EXIST geckpu-nv-14.dll (
            ECHO "Moving Power Up Plugin to Desktop"
            MOVE geckpu-nv-14.dll "C:\Users\Anonymous\Desktop\"
            ECHO "Move Power Up Plugin to Desktop SUCCESS"
            PAUSE
            GOTO RunGECK
        ) Else (
            ECHO "Plug-in not found! Try again."
            PAUSE
            GOTO StartProgram
        )
    ) Else (
        IF %UsePowerup%==1(

            cd /d "C:\Users\Anonymous\Desktop\"
            If EXIST geckpu-nv-14.dll (
                ECHO "Moving Power Up Plugin to GECK"
                MOVE geckpu-nv-14.dll "C:\Program Files (x86)\Steam\SteamApps\common\Fallout New Vegas\Data\NVSE\Plugins\"
                ECHO "Move Power Up Plugin to Desktop SUCCESS"
                PAUSE
                GOTO RunGECK
            ) Else ( 
                ECHO "Plug-in not found! Try again."
                PAUSE
                GOTO StartProgram
            )
        ) Else ( 
            ECHO "INVALID CHOICE Try Again"
            PAUSE
            CLS
            GOTO StartProgram
        )
    )
)   
exit /b

:RunGECK
cd /d "C:\Program Files (x86)\Steam\SteamApps\common\Fallout New Vegas\"
nvse_loader -editor
exit

Upvotes: 1

Related Questions