Reputation: 13
I want to check in a batch script if the current user logged in is a certain user in the domain. what i had in mind was:
if %username% == "Some_User_Name" (
...
)
When I do this its just skip the part in the: (). I know the user name is correct.
can anyone tell me what is wrong and how to right it?
thanks
Upvotes: 1
Views: 5595
Reputation: 90
2 Solutions:
if %username% == (Value of %Some_User_Name%)
or
if "%username%"=="%Some_User_Name%" goto IfStatement
:IfStatement
(Your code here)
CASE SENSITIVE!
Upvotes: 1
Reputation: 64730
This works for me:
C:\> if %USERNAME% == abelenky echo Current User Found
Current User Found
Notes:
It is case-sensitive on the string compared against (abelenky
).
Putting in AbElEnKy
does not work.
However, it is not case-sensitive for the environment variable: %UsErNaMe%
worked just fine.
Upvotes: 1