Solved Batch: if %username%=something...

December 23, 2005 at 17:21:05
Specs: Windows XP Pro, 500mhz, 224mb

How can I compare a variable to a string of text in a batch script? What I mean, exactly is this:

if %username%="cup cakes" then goto begin

What I mean is "if username is 'cup cakes' then goto begin"

But I don't know how to do this.. is there something I'm doing wrong?

See More: Batch: if %username%=something...

Report •

December 23, 2005 at 17:39:44

You were nearly there.
Note the surrounding quotes and the
double equal signs.
if "%username%"=="cup cakes" goto begin

Report •

December 23, 2005 at 17:46:52

When I do that, it says the following on execution:

(script works normally)
cakes"=="cup cakes" was unexpected at this time

any ideas? Also, "cup cakes" is an example, the real two words are only letters also.

Report •

December 23, 2005 at 19:22:42
✔ Best Answer

Hi skater & dtech10,

This works here [w2k]

if "%username%"=="cup cakes" goto begin

If at first you don't succeed, you're about average.


Report •

Related Solutions

Ask Question