Avatar of AGS
AGS
 asked on

GetEnvironmentVariable('USERNAME') sometimes return an empty string, why?

I am using the GetEnvironmentVariable('USERNAME') system call in a Delphi application as part of the licensing system. For 99% of the users it works flawlessly, but for a few users the call sometimes returns an empty string. For those users it seems like the return of the call can change between empty and the correct username several times each day. Have anyone experienced anything similar and found a solution?

A bit of extra info:

- We log the username each time the application is started so we can see the changes.

- We have not been able to reproduce the problem on one of our own machines.

- According to the users they have not made any changes that could cause this e.g. they are logging in to the same PC with the same username as always.

- This has started occurring within the last few months, or at least it is happening much more frequently recently.

DelphiPC* Microsoft Windows

Avatar of undefined
Last Comment
AGS

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mirtheil

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
ste5an

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
AGS

ASKER
Thank you both of you! At least in one case it was due to the OneDrive bug, the username is not the primary identification, but it is sufficiently entangled in the licensing setup to cause problems when blank. We have made a fallback to GetUserName, we do not have enough data to verify that the problem is solved yet, but fingers crossed!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy