Quantcast
Channel: DIAdem topics
Viewing all articles
Browse latest Browse all 3197

Getting name, surname and department of logged-in user in DIAdem 2020

$
0
0

Hello everybody.

 

I am trying to obtain info about the user running my script so about a logged-in user. I wasn't able to find a way how to do it directly in DIAdem script but I found neat code for Windows VBS I guess (I am still kind of new in scripting so I'm not sure what typ of code it is):

 

' ***************************************************************************' UserName_SurName.vbs	' Gets the current user's first name and last name' ***************************************************************************SetobjSysInfo=CreateObject("ADSystemInfo")SetobjCurrentUser=GetObject("LDAP://"&objSysInfo.UserName)WScript.EchoobjCurrentUser.givenNameWScript.Echoobjcurrentuser.lastname
WScript.Echo objcurrentuser.department

But I wasn't able to obtain my desired info even though I tried to substitute WScript.Echo with MsgBox and whatnot.

 

I then tried to run the code externally from DIAdem like this:

dim myShell set myShell = CreateObject("Wscript.Shell") dim shellExec set shellExec = myShell.Run("C:\Users\MyUserName\Desktop\UserName_SurName.vbs") do while shellExec.Status = 0 '0: task is still running call pause(0.1) loop if shellExec.Status=1 then '1: task has finished msgbox shellExec.stdout.ReadAll end if

 

where UserName_SurName.vbs is the first code saved as .vbs on my desktop. This time again without a success.

Could you please help me to obtain the user name, surname and department either directly from DIAdem script or from the script I posted? What do I do wrong.

 

Thank you in advance.

 

Marek


Viewing all articles
Browse latest Browse all 3197

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>