Page 1 of 1 1
Topic Options
#9814 - 2001-06-22 10:33 AM Getting %username% on remote PC
Anonymous
Unregistered


Hi

How can I get the currently logged in user on remote PC's.
$Name = ReadValue("\\HOSTNAME\HKEY_Current_User\.....) is not working.

Greetings

Andre

Top
#9815 - 2001-06-22 01:13 PM Re: Getting %username% on remote PC
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
Username?

For username use the @USERID macro

Fullname?

For fullname use the @FULLNAME macro


_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
#9816 - 2001-06-22 02:04 PM Re: Getting %username% on remote PC
Anonymous
Unregistered


Hi Ghost

I think I haven't mentioned the problem clearly. On our network (>350 PC) I need to to some job's on HKCU and HKLM. It's not possible to do it on a logon script because the user has no access to HKLM. All I need is the currently logged in user on a PC so I can execute a command like
copy \\pcname\WINNT\Profiles\murphy\Start Menu\.... \\pcname\WINNT\Profiles\All Users\Start Menu\....

Greetings

raser

[This message has been edited by raser (edited 22 June 2001).]

Top
#9817 - 2001-06-22 04:09 PM Re: Getting %username% on remote PC
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
raser,
HKCU is not a 'real' hive. It is smoke and mirrors. If you open any remote registry, you can see for yourself.
I don't know how to tell who is logged on through a reg peek. Perhaps someone else on the board can enlighten. I use NBTSTAT to tell me who, if anyone, is logged on to a particular PC.
Have you thought of using SU to do reg mods? See http://kixtart.org/board/Forum1/HTML/002502.html

------------------
Laziness is the mother of invention.

Les Ligetfalvy

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#9818 - 2001-06-23 04:38 AM Re: Getting %username% on remote PC
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

On our site you will find a script inventory.kix, which
will create a list of @userid's who were logged on lately.
It isn't possible with additional software or procedure to register
the moment of logging off.
See our site http://home.wanadoo.nl/scripting .
Greetings.

------------------
Site map:

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#9819 - 2001-06-25 11:51 PM Re: Getting %username% on remote PC
Anonymous
Unregistered


Getting the id of the current user isn't exactly straight forward. Using SIDTONAME in Kix 2001 B2 can do it probably the simplist.

My logon script records the time, date, userid and sid to an INI file at logon time. If I want to know who is loggedon to a remote PC I just read the time and date and userid from the log file.

Otherwise you can resort to using Sysinternals "Loggedon.exe" tool. It is a bit clunky and you can't really use the out put reliably, in a script. But for a once in a while query it works just fine.

Top
#9820 - 2001-11-20 12:19 AM Re: Getting %username% on remote PC
Anonymous
Unregistered


Haven't been on the board for a while, so maybe a late reaction, but what about:
nbtstat -a HOSTNAME?
The currently logged on user is a unique name [03] on the remote system.

Top
#9821 - 2001-11-20 12:38 AM Re: Getting %username% on remote PC
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
I am not sure but I think this might be a catch22. You want to run kix during logon presumably but generally the username is not defined locally until after logon completes. Seems to me I have read that Win2000 can do this magic but I know Win9x can not & I don't think NT can do it.

You can try pushing a command file name into the runonce key & this will run just after logon completes when the username is fully defined.

_________________________
Jack

Top
#9822 - 2001-11-20 12:54 AM Re: Getting %username% on remote PC
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... since you dug this one up from its grave...

Flaap,
NBTSTAT is usually my first tool for interactive because it works on Wintendo as well, however it will not always report the logged on user if that user has logged on to more than one PC.

For NT/2K, I rely on NetUsers.exe from http://www.systemtools.com/free_frame.htm

Jack,
I believe the topic of this thread has to do with ascertaining the currently logged on user for a remote PC.

Gonna go wash my hands now...

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#9823 - 2001-11-20 11:52 AM Re: Getting %username% on remote PC
Anonymous
Unregistered


Les,

Thanks for your tip. The netusers tool is great!

Flaap

Top
#9824 - 2001-11-20 01:02 PM Re: Getting %username% on remote PC
Anonymous
Unregistered


You can also read the value in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

DefaultUserName contains the name of the last logged on user. In Windows 2000, this could be the UPN version of the username (user@domain.com).

If you have the policy to clear username of last logged on user, this will not be here.

Top
#9825 - 2004-06-25 07:19 PM Re: Getting %username% on remote PC
Wokkeltje Offline
Fresh Scripter

Registered: 2002-08-12
Posts: 31
Loc: Torhout, Belgium
a question about the defaultusername under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

what if a task is scheduled to run under an different admin account. Will that reg key be changed?

Or is this the name of the last logged on user (the one who sits in front of the PC)?

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1680 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.06 seconds in which 0.015 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org