Link to home
Create AccountLog in
Avatar of Zlord1
Zlord1

asked on

Who am I logged in as?

Alright, I'm not talking like the ctrl+alt+del thing where it says "you are logged in as computer/user".

When you go to windows->run "\\computername"

How can you figure out who you're logged into that server as?

Is there even a way?
I assume it would be done from command prompt; but I havne't been able to figure it out yet.

Thanks alot :)
Avatar of CarlWarner
CarlWarner
Flag of United States of America image

If you go to a Command Prompt, and type SET USERNAME, you should see your logged in user designation.
Avatar of Zlord1
Zlord1

ASKER

That didn't answer my question.

That will tell me who I am logged in as on the local computer, but not any servers.

I'm wondering how to tell with the servers.
If you type SET by itself at the Command Prompt, you will see all of the environmental variables assigned in your current session, including both USERNAME and COMPUTERNAME.  Type SET|more to get a view that doesn't scroll away from you in the Command Prompt window.

If you type SET USERNAME > MYLOGIN.TXT at the Command Prompt, you will see your logged in user name in that text file all by itself that you can use for further processing in another program, if that is what you wish.  EDIT MYLOGIN.TXT from the Command Prompt will open that file up in the text editor and show you what you have.
Your logging on as either guest or the local account. Unless it prompts you for un/pw.
Avatar of Zlord1

ASKER

DoTheDew,

Yes. It prompts me to type a password.

Perhaps this could be done through the net use command?
You can use this:
http://www.systemtools.com/cgi-bin/download.pl?NetUsers

and use the \\computername variable.

your best bet is to run it from the server, if not you have to be an admin (on the server) to be able to do it remotely.
If it prompts you do use a password then it is being stopped by the server or remote machine you are connecting to. Are you trying to connect to a share on another xp machine or a server? Either or, you want to have the same user account/password on the shared machine.
Sorry bout the post for the netusers download thats the wrong thing. Its for local logon only. My fault. Also by saying above that it is being "stopped" by the server/machine I mean it's denying access due to un/pw which I think you already figured out :)

How is the machine your connecting to setup?
Avatar of Zlord1

ASKER

I'm not entirely sure you are understanding my question.

I am able to login.

Alrigiht; I have three servers; named tech1,2 and 3 appropriately.

So, say I log into one. And under this same session; my friend logs into tech2.

How can I find out who he is logged on to tech2 as?
Same session? Say you do a fast user switch and go from user1 to user2. Then user 1 attaches to \\tech1\shared and then u switch to user2 and he attaches to \\tech2\shared.

Tech 1 will have User1 logged in and Tech 2 will have User2 logged in. basically whatever username you have is what your logging into the server as unless it prompts you for username and password then you enter it manually. If thats the case and he is putting in a username/password of his own and you want to know the username, I'm not sure how to help you. I think you can either Audit the log on or find software that shows logged in users. I'd have to research that a bit. Sorry if i'm getting confused.
if you have the Windows 2000 resourse kit, you can type whoami at a command prompt,but you need the resource kit
here's a vbs script that shows info about you (if you don't have the resource kit):

Dim i, s1, s2, WshNetwork, WshShell, WshEnvStrings, WshArgs, oDrives
On Error Resume Next

Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = CreateObject ("WScript.Shell")
Set WshEnvStrings = WshShell.Environment("PROCESS")
Set WshArgs = WScript.Arguments

' ID Information
s1 = "You are " & WshNetwork.UserDomain & "\" & WshNetwork.UserName & " on \\" & WshNetwork.ComputerName & _
      vbNewLine & " Logged into " & WshEnvStrings("LOGONSERVER") & VBNewLine & VBNewLine

' Network Share List
Set oDrives = WshNetwork.EnumNetworkDrives
s1 = s1 & "There are " & CStr(oDrives.length/2) & " active network shares: " & VBNewLine & VBNewLine
j = -1
For i = 0 to oDrives.Count - 1 Step 2
      
      if oDrives.Item(i) = "" then
            s1 = s1 & oDrives.Item(i+1) & VBNewLine
      else
            s1 = s1 & oDrives.Item(i) & " = " & oDrives.Item(i+1) & VBNewLine
      end if

      if oDrives.Item(i) = "I:" then
            j = i
      end if
Next



' Check Command Line Arguments for NOPAUSE parameter
j = 1
' s1 = s1 & VBNewLine & "Arg count = " & WshArgs.Count & VBNewLine
For i = 0 to WshArgs.Count - 1
'      s1 = s1 & " '" & WshArgs(i) & "'"
      if (WshArgs(i) = "NOPAUSE") or (WshArgs(i) = "nopause") then
            j = 0
'            s1 = s1 & " we should not stop "
      end if
Next

if j = 1 then WScript.echo(s1)
      
so, here's the short version that just lists logon name, pc and domain controller:

Dim i, s1, s2, WshNetwork, WshShell, WshEnvStrings, WshArgs, oDrives
On Error Resume Next
Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = CreateObject("WScript.Shell")
Set WshEnvStrings = WshShell.Environment("PROCESS")
Set WshArgs = WScript.Arguments
' ID Information
s1 = "You are " & WshNetwork.UserDomain & "\" & WshNetwork.UserName & " on \\" & WshNetwork.ComputerName & _
    vbNewLine & " Logged into " & WshEnvStrings("LOGONSERVER") & vbNewLine & vbNewLine
MsgBox s1
Avatar of Zlord1

ASKER

Gilbar,

Is there any way to make it check not for shared drives; but just for shared items?
The tech1,2, and 3 aren't shared drives; I just access them by \\tech#
You basically are asking how you can determine which username is being used to access a network share to tech2 (in your example). i.e. you could be logged into your PC with the username 'zlord', then connect to \\tech2\share using the 'zlord2' account when prompted.

Then you need to do the following:

1. Log on to tech2 (either directly or via Remote Desktop/Terminal Services)
2. Right-click MyComputer and choose 'Manage'
3. Select 'Shared Folders', then 'Open files'. Here you can view each username that is being used to access each folder/file.

Is this what you are after?
Use Remote Task Manager. (http://www.protect-me.com/download/rtm.zip)

Remote Task Manager (RTM) is a systems control interface that can be run from any remote Windows NT/2000/XP computer. This enables a Systems Administrator to control most aspects of a remote environment. The simple-to-use, tabbed interface separates applications, services, devices, processes, events, shared resources and performance monitor, making each of these very easy to control. A Systems Administrator can start or stop services or devices, add new services or devices, manage the run level and adjust the security (permissions, auditing and owner). The Process Function and the Task Manager allows remote termination and adjusting of priority. An Event Viewer lets the Administrator view all events as though they were being run on the host computer. The Performance Monitor displays a dynamic overview of the computer's performance (CPU and memory usage). RTM even supports remote installs, enabling a Systems Administrator to set up a service on remote machines without ever having to physically go to them. RTM adds the ability to lock/shutdown/reboot and to create processes on remote computers.

Hope this works for you!
Do let me know the results or if you need further assistance...

Carpe Diem!
Avatar of Zlord1

ASKER

CyberneticsConnoisseur and rbowall ~:~ I'm wondering if I can do this from my local computer; without accessing the remote server.
I already know how to do it from server view using the mstsc.
to findout any information of the remote system from your own pc, you would have be a domain admin or part of the admin group on the remote system. either way, you would still have to access the system to get any information.
1. Bring up a command prompt window
2. Type:
              runas /user:domain\adminusername mmc
3. In mmc, choose File->Add/Remove Snap in...
4. Click Add, then choose 'Shared Folders' from the list
5. Select the 'Another Computer' radio button and enter the hostname or IP of your server
6. Select the 'Open Files' option and click finish, close, then OK.
7. You can now browse through the open files/folders and view each username attributed to it
Avatar of Zlord1

ASKER

None of these people answered my quesiton, thus I request a refund of points.
Zlord1,

Have you tried any of the suggestions that myself and CyberneticsConnoisseur gave you?

If we had some feedback, then we would most likely be willing help you get the answer you need.
Avatar of Zlord1

ASKER

Rbowall, yes I attempted what you gave me, and it didn't work for my specific instance.

I ended up using a variant of what Gilbar gave me that I found online.
This saved as a vbs file worked for what I needed.

'-------------BeginFunction------------------'
Set oWshNet = CreateObject("WScript.Network")
 sComputerName = "tech2"

sUserName = GetConsoleUser(sComputerName)
If sUserName <> "" Then
MsgBox "Console user name: " & sUserName
Else
MsgBox "Console user name not found with QWINSTA.EXE"
End If

Function GetConsoleUser(sHost)
' Function will return console user name from QWINSTA.EXE
' Windows XP and Win2k3 Server only

Set oShell = CreateObject("Wscript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject")

sTempFile = oFS.GetSpecialFolder(2).ShortPath & "\" & oFS.GetTempName

'Run command via Command Prompt and use for /f to extract user name
'Dump results into a temp text file
oShell.Run "%ComSpec% /c for /f ""skip=1 Tokens=2"" %i in " _
& "('%SystemRoot%\System32\QWINSTA.EXE console /SERVER:" _
& sHost & "') do echo %i >" & sTempFile, 0, True

GetConsoleUser = "" 'init value

If oFS.FileExists(sTempFile) Then
'Open the temp Text File and Read out the Data
Set oTF = oFS.OpenTextFile(sTempFile)

'Parse the text file
Do While Not oTF.AtEndOfStream
GetConsoleUser = Trim(oTF.ReadLine)
Loop

'Close it
oTF.Close
'Delete It
oFS.DeleteFile sTempFile
End If

End Function
'--------------------8<----------------------
That looks good - may have a use for it myself. It is always best to follow a solution up if you subsequently find the answer as EE is used as a knowledgebase to help other people in the future with the same problem.

Lee Tutor - I agree that the points can be refunded to Zlord1, if this is the way you wish this to be closed.

Thanks
glad i could help zlord1
ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer