As you can see from the below code, I'm trying to work out which OS a machine is using and then based on this do different things. However, for some reason none of the if statements are executing their conditions.
When printing the contents of %osname% I noticed that there is a space after the string, which is why I've added that into the condition, but it didn't work either.
REM set variables
SET /P comp= Computer:
SET /P user= username:
ECHO Computer Selected = %comp%
ECHO Username Selected = %user%
FOR /F "tokens=2 delims='='" %%A in ('wmic %cstring% os get Name /value') do SET osname=%%A
FOR /F "tokens=1 delims='|'" %%A in ("%osname%") do SET osname=%%A
ECHO Operating System: %osname%
if %osname% == "Microsoft Windows XP Professional " (
if %osname% == "Microsoft Windows 7 Professional " (
if %osname% == "Microsoft® Windows VistaT Business " (
echo blah blah A
echo blah blah B
echo blah blah C