$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>asp.net - ActiveXobject error in javascript - Stack Overflow|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

asp.net - ActiveXobject error in javascript - Stack Overflow

matteradmin11PV0评论

I use ths script in Default.aspx page.

<script id="clientEventHandlersJS" type="text/javascript">

        function Button1_onclick() {
            var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
            var service = locator.ConnectServer(".");
            var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
            var e = new Enumerator (properties);
            document.write("<table border=1>");
            dispHeading();
            for (;!e.atEnd();e.moveNext ())
            {
                var p = e.item ();
                document.write("<tr>");
                document.write("<td>" + p.Caption + "</td>");
                document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
                document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
                document.write("<td>" + p.IPXAddress + "</td>");
                document.write("<td>" + p.IPXEnabled + "</td>");
                document.write("<td>" + p.IPXNetworkNumber + "</td>");
                document.write("<td>" + p.MACAddress + "</td>");
                document.write("<td>" + p.WINSPrimaryServer + "</td>");
                document.write("<td>" + p.WINSSecondaryServer + "</td>");
                document.write("</tr>");
            }
            document.write("</table>");
        }
        function dispHeading()
        {
            document.write("<thead>");
            document.write("<td>Caption</td>");
            document.write("<td>IPFilterSecurityEnabled</td>");
            document.write("<td>IPPortSecurityEnabled</td>");
            document.write("<td>IPXAddress</td>");
            document.write("<td>IPXEnabled</td>");
            document.write("<td>IPXNetworkNumber</td>");
            document.write("<td>MACAddress</td>");
            document.write("<td>WINSPrimaryServer</td>");
            document.write("<td>WINSSecondaryServer</td>");
            document.write("</thead>");
        }
    </script>

in above code I am trying to fetch MAC address of client. But i am getting error at first line `var locator = new ActiveXObject ("WbemScripting.SWbemLocator");'

that activeX object cant be created, please help me.

I use ths script in Default.aspx page.

<script id="clientEventHandlersJS" type="text/javascript">

        function Button1_onclick() {
            var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
            var service = locator.ConnectServer(".");
            var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
            var e = new Enumerator (properties);
            document.write("<table border=1>");
            dispHeading();
            for (;!e.atEnd();e.moveNext ())
            {
                var p = e.item ();
                document.write("<tr>");
                document.write("<td>" + p.Caption + "</td>");
                document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
                document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
                document.write("<td>" + p.IPXAddress + "</td>");
                document.write("<td>" + p.IPXEnabled + "</td>");
                document.write("<td>" + p.IPXNetworkNumber + "</td>");
                document.write("<td>" + p.MACAddress + "</td>");
                document.write("<td>" + p.WINSPrimaryServer + "</td>");
                document.write("<td>" + p.WINSSecondaryServer + "</td>");
                document.write("</tr>");
            }
            document.write("</table>");
        }
        function dispHeading()
        {
            document.write("<thead>");
            document.write("<td>Caption</td>");
            document.write("<td>IPFilterSecurityEnabled</td>");
            document.write("<td>IPPortSecurityEnabled</td>");
            document.write("<td>IPXAddress</td>");
            document.write("<td>IPXEnabled</td>");
            document.write("<td>IPXNetworkNumber</td>");
            document.write("<td>MACAddress</td>");
            document.write("<td>WINSPrimaryServer</td>");
            document.write("<td>WINSSecondaryServer</td>");
            document.write("</thead>");
        }
    </script>

in above code I am trying to fetch MAC address of client. But i am getting error at first line `var locator = new ActiveXObject ("WbemScripting.SWbemLocator");'

that activeX object cant be created, please help me.

Share Improve this question asked Mar 27, 2009 at 5:49 VikasVikas 24.4k37 gold badges119 silver badges159 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

The WbemScripting objects are not marked as "Safe for scripting", and rightly so! If they were, any web page could figure out what processes you are running, terminate them, and even launch new applications! Talk about a security breach...

The WbemScripting objects are made for use in Windows Scripting, not for use in a web page.

If you have access to the client machine, try running your code from a .js file using WScript.exe or CScript.exe. If the client machine is within your network and you know its name, you could also try running the script remotely; just replace the "." period in the line

locator.ConnectServer(".");

by the machine's name. So if the remote machine's name is MACHINE, you should change the line to

locator.ConnectServer("MACHINE");

Again, this would require you to run the script from a .js file using WScript or CScript.

Lastly, you could try to lower Internet Explorer's security settings on the client machine. But only do this if you never surf the big bad internet with that machine, since it'll open up your browser, your entire PC and all of the network connected to it to all kinds of unsavoury stuff...

Check to make certain that the COM object you are trying to create is installed, and marked as safe for scripting. Confirm your security settings in IE. Beyond this, ActiveXObject is only available via IE, not other browsers. Most likely is it either isn't "safe for scripting", or your security settings for the security domain forbid it.

Post a comment

comment list (0)

  1. No comments so far