Josh Hunt
Josh Hunt

Reputation: 29

Batch: The syntax of the command is incorrect?

I can't find the error I have spent a long time trying to fix this error but I can't find the error.

The Batch file keeps giving me The syntax of the command is incorrect when I run the following codes.

What's wrong with it?

Code:

@echo off 

whoami /groups | find "S-1-16-12288" > nul

if %errorlevel% == 0 (
goto :Runing in Admin Mode
) ELSE (
goto :Not Runing in Admin Mode
)

if %errorlevel% == 2 (
goto :Not Runing in Admin Mode
) ELSE (
goto :Runing in Admin Mode
)

SET AND=IF
SET THEN=(
SET ELSE=) ELSE (
SET NOELSE=
SET ENDIF=)
SET BEGIN=(
SET END=)
SET RETURN=EXIT /B

:Runing in Admin Mode
if %errorlevel% == 0 (
echo Runing in Admin Mode
echo.
attrib -h FileCompressionTool.bat

IF EXIST "upx.exe" %THEN%
attrib -h upx.exe
set missingfilesFalse=False
%ELSE%
 echo upx.exe. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

IF EXIST "mpress.exe" %THEN%
attrib -h mpress.exe
set missingfilesFalse=False
%ELSE%
echo mpress.exe. missing.
set missingfilesTrue=True
ping >nul 3 
%THEN%

IF EXIST strip.exe  %THEN%
attrib -h strip.exe
%ELSE%
echo strip.exe. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

IF EXIST reshacker.exe  %THEN%
attrib -h reshacker.exe
%ELSE%
echo reshacker.exe. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

IF EXIST reshacker.ini %THEN%
attrib -h reshacker.ini
%ELSE%
echo reshacker.ini. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

IF EXIST reshacker.Log %THEN%
attrib -h reshacker.Log
%ELSE%
echo reshacker.Log. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%

cls

:Not Runing in Admin Mode
if %errorlevel% == 2 (
echo Not Runing in Admin Mode
echo.

attrib -h FileCompressionTool.bat

IF EXIST "upx.exe" %THEN%
attrib -h upx.exe
set missingfilesFalse=False
%ELSE%
echo upx.exe. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

IF EXIST "mpress.exe" %THEN%
attrib -h mpress.exe
set missingfilesFalse=False
%ELSE%
echo mpress.exe. missing.
set missingfilesTrue=True
ping >nul 3 
%THEN%

IF EXIST strip.exe  %THEN%
attrib -h strip.exe
%ELSE%
echo strip.exe. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

IF EXIST reshacker.exe  %THEN%
attrib -h reshacker.exe
%ELSE%
echo reshacker.exe. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

IF EXIST reshacker.ini %THEN%
attrib -h reshacker.ini
%ELSE%
echo reshacker.ini. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

IF EXIST reshacker.Log %THEN%
attrib -h reshacker.Log
%ELSE%
echo reshacker.Log. missing.
set missingfilesTrue=True
ping >nul 3 %THEN%

%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%
%NOELSE%
%ENDIF%

cls

IF EXIST "%~1" %THEN%
SET "result=%~1"
%ELSE%
SET "result="
%ENDIF%

set False= Pause

set True=echo Some file are missing this program may not work correctly please Re-download                                         **File Compression Tool**


echo 1 UPX Compression
echo 2 Mpress Compression
echo 3 Decompress a file
echo 4 Remove VB6 default icon
echo Type exit to exit 
echo.
if "%missingfilesTrue%"=="True" %true%

Set /p choice= 
If %choice%==1 goto :1
If %choice%==2 goto :2
If %choice%==3 goto :3
If %choice%==4 goto :4
If %choice%==exit goto :exit

if %missingfilesTrue%==True(
 %true%
) else (
if %missingfilesFalse%==False
%False%
)

goto :exit

:1
cls
echo ***Drag your exe file into this window and press enter***
set /p File=: 
echo.
copy %file% %file%.bak
upx --best %file%
echo.
echo Done!
echo Press any key to exit. . .
pause >nul
goto exit

:2
cls
echo ***Drag your exe file into this window and press enter***
set /p file=: 
echo.
copy %file% %file%.bak
Mpress -s %file%
echo.
echo Done!
echo Press any key to exit. . .
pause >nul
goto exit

:3
cls
echo ***Drag your exe file into this window and press enter***
set /p file=: 
echo.
copy %file% %file%.bak
upx -d %file%
echo.
echo Done!
echo Press any key to exit. . .
pause >nul
goto exit

:4
cls
echo ***Drag your exe file into this window and press enter***
set /p thefile=:

(
reshacker -delete %thefile%, %thefile%, ICONGROUP, 1, 0
)

strip -s --strip-all -g -S -d --strip-debug -x --discard-all -X --discard-locals %thefile%
upx -9 %thefile%
echo.
echo Done!
echo Press any key to exit. . .
pause >nul
goto exit

:exit
Exit

Upvotes: 2

Views: 1538

Answers (1)

Magoo
Magoo

Reputation: 79982

if %errorlevel% == 0 (
goto :Runing in Admin Mode
) ELSE (
goto :Not Runing in Admin Mode
)

Will goto the label :Runing if errorlevel is 0 and to the label :Not otherwise (and since not is a batch keyword, that's a terrible but not illegal name for a label)

Since the variables "Then" etc have not been established at that point, they will be replaced by their then-current values (ie. nothing) and - well, in such a slab of code, I'll not be bothering working out the result. Follow the comment about the @echo off and the syntax-error of the constructed command will be shown.

Upvotes: 1

Related Questions