Community discussions

MikroTik App
 
jamwatn1
just joined
Topic Author
Posts: 4
Joined: Wed Jun 04, 2014 6:11 pm

How to show current user

Thu Jun 05, 2014 8:43 pm

Just want to see if anyone could help me?
Im looking to show the Current logged on Windows user when hovering over a computer.
One way I thought it might be possible is scripting a way of showing the most recent folder in C:/Users and fetching the name of it. EG: C:/Users/User01 and having the name of that folder show up.
Hope someone can help?

Justin
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12008
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to show current user

Fri Jun 06, 2014 8:33 pm

Go to Microsoft forum, this is MikroTik forum.
 
jamwatn1
just joined
Topic Author
Posts: 4
Joined: Wed Jun 04, 2014 6:11 pm

Re: How to show current user

Fri Jun 06, 2014 8:38 pm

I'm asking about The Dude not a Microsoft product
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12008
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to show current user

Fri Jun 06, 2014 8:41 pm

I'm asking about The Dude not a Microsoft product
The most reccent folder can be also 1990 (for example)...

The user folder is created when the first time the specified user are logged, and is not updated for every logon.
 
jamwatn1
just joined
Topic Author
Posts: 4
Joined: Wed Jun 04, 2014 6:11 pm

Re: How to show current user

Fri Jun 06, 2014 10:28 pm

It is when using roaming profiles. When a user logs on to a box, a copy of their profile is downloaded/modified. If I could get the dude to find the recently modified folder in c:/users it could display who is logged on theoretically.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12008
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to show current user

Sat Jun 07, 2014 1:22 am

Can be...
 
keithBy
just joined
Posts: 3
Joined: Sat Jun 07, 2014 1:25 am

Re: How to show current user

Sat Jun 07, 2014 1:35 am

I added this to the appearance of the computer

[Logged_in_User()] Which is the following function

array_element(execute("cscript.exe",concatenate("//NoLogo C:\\ra\\whoisloggedon.vbs ",User_Pass()),"C:\\WINDOWS\\system32\\"),1)

whoisloggedon.vbs is the following script

'loggeduser.vbs
' Sample VBScript to discover which user is logged on
' Author Guy Thomas and John Eck
' Version 2.5 - December 2005
' -------------------------------------------------------'
'Modified by gsandul to logon to remote host using
'username and password specified from command line
'

'Set objPassword = CreateObject("ScriptPW.Password")

'strComputer = "192.168.0.60"

'You can uncomment the following 3 lines and
'specify hardcoded domain, username and password

strDomain = "xxx"
strUser = "xxxxxx"
strPassword = "xxxxxxx"

'wscript.echo wscript.arguments(0)
', wscript.arguments(1), wscript.arguments(2), wscript.arguments(3)
strComputer = wscript.arguments(0)

'If you hardcoded domain, username and password
'comment the following 3 lines

'strDomain = wscript.arguments(1)
'strUser = wscript.arguments(2)
'strPassword = wscript.arguments(3)

'wscript.echo strdomain, struser, strpassword

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer, _
"root\CIMV2", _
strUser, _
strPassword, _
"MS_409", _
"NTLMDomain:" + strDomain)
' You suppose to be authentificated
' Now you can write any WMI function

Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
If not objComputer.UserName = "" Then
strLogonUser = Split(objComputer.UserName,"\")
strLogonUser(1) = UCase(Left(strLogonUser(1),1))& Trim(Mid(strLogonUser(1),2,20))
Wscript.Echo strLogonUser(1)
'Wscript.Echo strLogonUser(1) & " is logged on to " & strComputer
Else
Wscript.Echo "No_one_is_logged"
End If
Next

' End of Sample Logged on VBScript

Who is online

Users browsing this forum: No registered users and 47 guests