Link to home
Start Free TrialLog in
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.

ASKER CERTIFIED SOLUTION
Avatar of Mirtheil
Mirtheil
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AGS
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!