Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Who am I? (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: databases
Next thread: reference object by string


Who am I?   -   Andrew Keller
  Re: Who am I?   -   Seth Willits
  Re: Who am I?   -   Mike Bailey
  Re: Who am I?   -   Mark Guertin
  Re: Who am I?   -   Seth Willits
  Re: Who am I?   -   Andrew Keller
  Re: Who AM I?   -   Patrick Besong
  Re: Who am I?   -   Jonathan Johnson

Who am I?
Date: 03.02.04 23:49 (Tue, 3 Feb 2004 17:49:49 -0500)
From: Andrew Keller
Is there an easy way to figure out what the short name of the logged in
user is on a machine? I would like to be able to do this on Mac OSX
and Windows.

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Who am I?
Date: 04.02.04 00:15 (Tue, 3 Feb 2004 15:15:22 -0800)
From: Seth Willits
On Feb 3, 2004, at 2:49 PM, Andrew Keller wrote:

> Is there an easy way to figure out what the short name of the logged
> in user is on a machine? I would like to be able to do this on Mac
> OSX and Windows.

On OS X it's a small shell command "echo $user"



Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames

Friendship is a beautiful thing. "The best and most beautiful things in
the
world cannot be seen or even touched - they must be felt with the
heart."
-- Hellen Keller
------------------------------------------------------------------------
---

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Who am I?
Date: 04.02.04 16:24 (Wed, 4 Feb 2004 09:24:21 -0600)
From: Mike Bailey
On Feb 3, 2004, at 4:49 PM, Andrew Keller wrote:

> Is there an easy way to figure out what the short name of the logged
> in user is on a machine? I would like to be able to do this on Mac
> OSX and Windows.

Coincidentally your subject line will work on Mac OS X (with slight
modifications).

Execute the shell command 'whoami':

dim sh as shell
sh = new shell
sh.execute "whoami"
msgBox sh.result

Re: Who am I?
Date: 04.02.04 18:13 (Wed, 4 Feb 2004 12:13:55 -0500)
From: Mark Guertin
On 3-Feb-04, at 6:15 PM, Seth Willits wrote:

> On Feb 3, 2004, at 2:49 PM, Andrew Keller wrote:
>
>> Is there an easy way to figure out what the short name of the logged
>> in user is on a machine? I would like to be able to do this on Mac
>> OSX and Windows.
>
> On OS X it's a small shell command "echo $user"
>

That assumes the shell command inherits the environment properly. I
would be more inclined to use the command whoami in OSX than to trust
that the env variable will always be there and/or correct (especially
going into the future).

Mark

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Who am I?
Date: 04.02.04 20:39 (Wed, 4 Feb 2004 11:39:08 -0800)
From: Seth Willits
>> On OS X it's a small shell command "echo $user"
>
> That assumes the shell command inherits the environment properly. I
> would be more inclined to use the command whoami in OSX than to trust
> that the env variable will always be there and/or correct (especially
> going into the future).

Good point. I did think about whoami, but why I didn't reply with it is
beyond me :) I guess I'm just used to echo for some reason.


Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames

"Not everything that can be counted counts, and not everything that
counts
can be counted."
-- Albert Einstein
------------------------------------------------------------------------
---

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Who am I?
Date: 05.02.04 03:30 (Wed, 4 Feb 2004 21:30:12 -0500)
From: Andrew Keller
What is the Windows equivalent of the Terminal command "whoami" or
"echo $user"?

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Who AM I?
Date: 05.02.04 13:54 (Thu, 5 Feb 2004 07:54:51 -0500)
From: Patrick Besong
>> Is there an easy way to figure out what the short name of the logged
>> in user is on a machine? I would like to be able to do this on Mac
>> OSX and Windows.

On Mac OSX, I was able to simply say:

DesktopFolder.parent.name

*******************************************************
Pat Besong ?:-{>
Research Programmer, Faculty Multimedia Center
212 Rider II Bldg. University Park, PA 16802
<email address removed> 814-865-2154
*******************************************************

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Who am I?
Date: 05.02.04 15:16 (Thu, 5 Feb 2004 08:16:33 -0600)
From: Jonathan Johnson

On Feb 4, 2004, at 8:30 PM, Andrew Keller wrote:

> What is the Windows equivalent of the Terminal command "whoami" or
> "echo $user"?

I just worked on this, and I haven't tested it on anything other than
Windows 2000. According to MSDN, it's available on anything from
Windows 95 and up.

Here's the entire method that works on both OS X and Windows:

Function CurrentUser() As String
#if TargetWin32 then
declare function GetUserName lib "advapi32" alias "GetUserNameA"
(lpBuffer as Ptr, byref nSize as Integer) as Integer

dim name as String
dim buffer as MemoryBlock
dim size,err as Integer

size = 256
buffer = new MemoryBlock(size) // Note, if people's login names
can be longer than 256, this will fail
// However, my guess is that it's
probably just fine this way

err = GetUserName(buffer,size)

if err <> 0 then
name = buffer.CString(0)
end if

return name
#else
#if TargetCarbon then
dim sh as shell
sh = new Shell
sh.Execute "whoami"
return sh.result
#endif
#endif
End Function

Hope this helps,
Jon