1

I have a code in my HTML to discover the user name using :

    var objUserInfo = new ActiveXObject("WScript.network");    
    var uname =  objUserInfo.UserName;

Unfortunately, this code only works in IE. Whats the equivalent code in JS ? I want to run this on Chrome or other non-IE browser. I have not so good alternative (cos vbs will be deprecated in html.. right ?) such as writing VBS but dont know how to call this via HTML :

Dim strCmd
    strCmd = "cmd /q /c ""quser console | find /i ""console"" "" "

Dim buffer 
    buffer = WScript.CreateObject("WScript.Shell").Exec(strCmd).StdOut.ReadAll()

Dim c, consoleUserName
    c = InStr(buffer,"console")
    If c > 2 Then
        consoleUserName = Trim(Mid(buffer,2,c-2))
    Else
        consoleUserName = ""
    End If

    WScript.Echo consoleUserName

Another alternative is i put an IE-Tab extension on Chrome so that it can run . Works, but it doesn't look aesthetically good. :)

Do you know any other possible ways ? My Web Server is IIS

Thanks

padjee
  • 125
  • 2
  • 12

1 Answers1

1

ActiveX objects will not work in other browsers, only supported in IE. If you are developing chrome extensions you might need to look into some of chrome API More info: https://developer.chrome.com/extensions/api_index No wide support for Shell, Network as provided via ActiveXObjects

Krishna
  • 41
  • 3
  • As I said, I know its not working... Is there any equivalent of that code written in JS ? Or maybe any other equivalent so that I can extract user name ? – padjee Jan 21 '19 at 03:09