Hello,
I need in SCADA to get the windows User Name.
Does someone knows how to do it
I tried this but it makes PcVue crash:
DECLARE FUNCTION GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As STR, nSize As Long) AS LONG; 'WindowsUser
Sub Main()
Dim strName As Str;
GetUserName(strName,255);
End Sub
You can use this in VBA
MsgBox VBA.Interaction.Environ$("UserName")
This one is basic and it doesn't send back the domain but only the username.
For more details, you can execute this code
Sub GetDetails()
Dim ObjWshNw As Object
Set ObjWshNw = CreateObject("WScript.Network")
MsgBox ObjWshNw.UserName
MsgBox ObjWshNw.ComputerName
MsgBox ObjWshNw.UserDomain
End Sub
Nico
Thank you Nico.
Finally I didi it in VBA.
But I would had prefered in SCADA


