Syntax error

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Docfxit
Posts: 14
Joined: 12 Nov 2015 12:42

Syntax error

#1 Post by Docfxit » 31 Jan 2019 00:03

I'm getting this error:
( was unexpected at this time.

Code: Select all

set "_WinVer=Windows 10"
Just before this code:

Code: Select all

If "%_WinVer%==Windows 10" (
bcdedit.exe /create /d "Windows 10" /application osloader >"%~dp0BootFixerGUID.txt"
)
pause
Else
::Now we have a clean, working Win 7 bootloader. But we need to add a Win 7 entry to it:
If "%_WinVer% = Win7  or server 2008 R2" (
bcdedit.exe /create /d "Windows 7" /application osloader >"%~dp0BootFixerGUID.txt"
)
Please help me fix this,

Docfxit

miskox
Posts: 327
Joined: 28 Jun 2010 03:46

Re: Syntax error

#2 Post by miskox » 31 Jan 2019 01:14

Try with this:

change

Code: Select all

If "%_WinVer%==Windows 10" (
to

Code: Select all

If "%_WinVer%"=="Windows 10" (
Correct everywhere.

Saso

Squashman
Expert
Posts: 4050
Joined: 23 Dec 2011 13:59

Re: Syntax error

#3 Post by Squashman » 31 Jan 2019 07:44

You have two other code problems as well.

The proper syntax for using IF ELSE is clearly defined in the help file for the IF command. Your code is not even remotely close.

Code: Select all

IF "something"=="something" (
	echo do this
) ELSE (
	echo do that
)
Also there is no OR operator defined in the help file for the IF command. You need to chain together multiple IF command to essentially do an OR.

pieh-ejdsch
Posts: 182
Joined: 04 Mar 2014 11:14
Location: germany

Re: Syntax error

#4 Post by pieh-ejdsch » 31 Jan 2019 07:53

Hello Docfxit,

Just call the right place in the script.
Then the many comparisons are omitted.

Code: Select all

@echo off
setlocal

for /f "eol=Ctokens=2-6delims=cropfestivnawld®. " %%a in ('"WMIC os get caption"') do call :%%a%%b%%c%%d%%e
if errorlevel 1 echo NOT used ...

pause
exit /b

:WRT81-
echo %0
exit /b 0  

:W7P
:W7E
echo %0

 rem do it at seven
exit /b 0

:W10P
echo %0
exit /b

:WS2008S
echo %0
exit /b 0 
 
:WS2008R2S
:WS2008R2E
echo %0
 rem do it at Server R2

exit /b 0

REM Ausgaben der Abfrage bei den unterschiedlichen Betriebsystemen:
 REM Microsoft Windows 7 Professional
 REM Microsoft Windows 7 Enterprise
 REM Microsoft® Windows Server® 2008 Standard
 REM Microsoft Windows Server 2008 R2 Standard
 REM Microsoft Windows Server 2008 R2 Enterprise
 REM Microsoft Windows XP Professional
 REM Microsoft Windows 10 Pro
Phil

Docfxit
Posts: 14
Joined: 12 Nov 2015 12:42

Re: Syntax error

#5 Post by Docfxit » 31 Jan 2019 11:27

That is excellent. It's working perfectly now. You are all really great for helping me fix this.

Thanks a bunch,

Docfxit

Post Reply