Jump to content

How can check a logged user's name?


nyirog
 Share

Recommended Posts

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?

Link to comment
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?)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...