Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a simple bat file?

Tags:

batch-file

I am writing a simple batch file and i get this "The syntax of the command is incorrect" error for the if statement.The batch file is as below:

@echo off

set ARCH=%PROCESSOR_ARCHITECTURE%

if %ARCH% == 'x86'
(
)

I also tried

if %ARCH% EQU 'x86'

What is wrong with the if statement?

like image 291
Sam Avatar asked Jan 18 '26 08:01

Sam


1 Answers

try

@echo off
set ARCH=%PROCESSOR_ARCHITECTURE%
if %ARCH% == x86 ( echo ok )
rem or %ARCH% EQU x86

and while you are at it, why not learn vbscript as well, here's the equivalent

Set WshShell = WScript.CreateObject("WScript.Shell")
Set Wsharch = WshShell.Environment("SYSTEM")
arch=Wsharch.Item("PROCESSOR_ARCHITECTURE")
If arch = "x86" Then
    WScript.Echo "PROCESSOR_ARCHITECTURE is x86"
End If
' if Instr(arch,"86") > 0 then
like image 163
ghostdog74 Avatar answered Jan 21 '26 06:01

ghostdog74



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!