Here are 3 ways to get the username.
1. Use the door library with this:
AddObject("objEnv","Object")
objEnv.New1(False)
objEnv.CreateNew("System.Environment" & objEnv.System_Mscorlib)
username = objEnv.GetProperty("UserName")
machinename = objEnv.GetProperty("MachineName")
2. Use the Command line to write the username to a file with this:
Shell("cmd"," /Q /C echo %username% > "&AppPath&"\username.txt")
Sleep(500)
If FileExist(AppPath&"\username.txt") = True Then
FileOpen(c1, AppPath&"\username.txt", cRead)
username = FileReadToEnd(c1)
FileClose(c1)
FileDel(AppPath&"\username.txt")
End If
3. Use the attached Environment library with this:
AddObject("env","Environment")
env.New1
username = env.UserName
If you are already using the Door library, then the first way is probably the easiest.
The command line way, doesn't require an additional library, on very rare occasions the cmd window pops up, despite using the /Q parameter which should surpress that. I'm not sure if it's 100% reliable if Account permissions interfer with the file writing.
The Environment library is just a quick wrapper I wrote to access the System.Environment Class(desktop only), it gives you access to username, machinename and let's you get any other variable via GetSystemVariable(source code included so it gets merged when compiling)