Sign in to follow this  
Followers 0
nyirog

How can check a logged user's name?

5 posts in this topic

In our company there are 2 kind of users: the company's own users has a simple username (example abcd, efgh, xyza, etc.), and the vendor users have "a-" before their username (example a-abcd, a-efgh, a-xyza, etc)

I would like to prevent my scripts against vendor users. I would have a check: Is the logged on user has an "a-" user, or a simple? If he/she has simple user, the script start normally, but if the username start with "a-" then get an error message. (for example: You are not authorized to run this program)

How can I do this?

Share this post


Link to post
Share on other sites



For sure there are better ways but some easy way would be to check the %userprofile% variable

It holds the username of the currently logged in user.

C:\Documents and Settings\username

Share this post


Link to post
Share on other sites

For sure there are better ways but some easy way would be to check the %userprofile% variable

It holds the username of the currently logged in user.

C:\Documents and Settings\username

ok, you are right, i know it, but how can i check this username start with "a-" or not? (maybe read it to a string, but is there a command to check string's first character?)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$result = StringLeft(@UserName , 2)
MsgBox(0, "Leftmost 2 characters are:", $result)

Yes- try this example

@edit - small error correction

Edited by Juvigy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0