using "IF" or "IF [NOT]" to run a command. The variable is the logged on %username%
Posted on 2003-12-03
Hi there all,
I'm in the middle of writing a batch job that'll hopefully run an executable ONLY if the currently logged in user is "Administrator"
I've tried this for starters:
IF [NOT] %username%==administrator GOTO :1
However, this seems to stop the batch process and it will not use the GOTO command. What I get as the output is:
%mycurrentusername%==administrator was unexpected at this time
Essentially, I want to parse the logged on user, and use the value it returns to either run the .exe or not
Any help would be much appreciated.