Computing.Net > Forums > Windows XP > Batch: if %username%=something...

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch: if %username%=something...

Reply to Message Icon

Name: skater123
Date: December 23, 2005 at 17:21:05 Pacific
OS: Windows XP Pro
CPU/Ram: 500mhz, 224mb
Comment:

Hi
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?



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: December 23, 2005 at 17:39:44 Pacific
Reply:

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


0

Response Number 2
Name: skater123
Date: December 23, 2005 at 17:46:52 Pacific
Reply:

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.


0

Response Number 3
Name: Mechanix2Go
Date: December 23, 2005 at 19:22:42 Pacific
Reply:

Hi skater & dtech10,

This works here [w2k]

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


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

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Upgrading using OEM XPpr... clicking noises with medi...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Batch: if %username%=something...

batch file to move folder from a DB www.computing.net/answers/windows-xp/batch-file-to-move-folder-from-a-db/168622.html

In case something goes wrong is ... www.computing.net/answers/windows-xp/in-case-something-goes-wrong-is-/130948.html

Batch file help needed... www.computing.net/answers/windows-xp/batch-file-help-needed/163063.html