%username%

WellingtonIS
WellingtonIS used Ask the Experts™
on
I have a bunch of user names on a file server for example smithj.  The individuals user name is wrmsmithj.  I was wondering if there is a way to take the variable %username% and tell it to leave out the wrm and just use the name.  I'm not sure this can be done so if anyone knows or can point me in the right direction it would be much appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012

Commented:
%username% will use the username you can't trim anything off this variable.

The variable is what it is.
%username% is the variable which get's replaced with the actual username.. you cannot change it..

Author

Commented:
so basically it's only going to read what's in the username field.  OK I was hoping to avoid that and maybe tell it -wrm but decision time.
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Joseph MoodyBlogger and wearer of all hats.

Commented:
You could establish a new environment variable using Group Policy Preferences. For example, we establish a variable that equals Last Name - First Intial.

Author

Commented:
The way I inherited this mess was the user's 1st five letters of last name followed by 1st initial of the 1st name.  It's such a mess.  I'm afraid if I use the prefix in front of the user names that
a)I won't be able to find anything and
b)when the user logs  into the computer they will be waiting forever for the documents to redirect to the new folders with the new user names.  Some of those user folders contain almost a gig of "junk"
Senior Solutions Architect
Commented:
It depends on what you want to do with the variable.
Most programming languages have string manipulation functions that can strip the wrm from the variable and save it as another variable.

e.g. for dos batch files
echo %username:~3,99%

Open in new window


This code will show you the %username% variable starting from the 4th character.
If username: wrmsmithj then the expected output would be smithj
similarly if username was 123myName it would strip the 123, and return myName.

Other programming languages all have similar functions...

Another alternative would be to contruct the user name based on the known rule of 1st 5 letters of surname and 1st letter of first name.

Author

Commented:
OK that's a start.  Thanks.  I think I will be able to use this.

Author

Commented:
Thx.  This is what I need to get started.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial