Microsoft JScript runtime error: Automation server can't create object
<p>Trying to get UserName and used code below to obtine this. Note if I Call the function from button it shows correct user name in pupup window.</p>

<pre><code>&lt;body onload = "GetUserName();"&gt;
    &lt;script language="javascript" type="text/javascript"&gt;
    function GetUserName() {
         var WinNetwork = new ActiveXObject("WScript.Network");
        //alert(WinNetwork.UserName);
         var userName = WinNetwork.UserName;
        //var userName = 'test';
        document.getElementById('label1').innerHTML = userName;
    }
    &lt;/script&gt;
    &lt;form runat="server"&gt;    
    &lt;asp:HiddenField ID="hfUserName" runat="server" value="a"/&gt;
    &lt;asp:PlaceHolder ID="phLabelUser" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
</code></pre>

<p>in code behind I create label to show it but intention is to use hidden controller </p>

<pre><code>    Label label= new Label();
    label.ID = "lbl1";
    label.Text = "test -&gt; " + hfUserName.Value;
    phLabelUser.Controls.Add(label);
</code></pre>

<p>I Enabled the following settings in IE so there is no security issues the site is on intranet.</p>

<pre><code>Run ActiveX controls and plug-ins
Initialize and script ActiveX controls not marked as safe.
</code></pre>

<p>Why this would create an error in debuger?</p>

<p>"Microsoft JScript runtime error: Automation server can't create object" </p>
