lostpencil 阅读(1441) 评论(4)
        <script type="text/javascript">
         
<!-- 
function runExecutable() 

    
//var executableFullPath = 'E:\greentools\eclipse\eclipse-SDK-3.6-win32\eclipse\eclipse.exe'; 
    var executableFullPath = "C:\sock.exe"

    
try 
    

        var shellActiveXObject 
= new ActiveXObject("WScript.Shell"); 

        
if ( !shellActiveXObject ) 
        

             alert(
'Could not get reference to WScript.Shell'); 
             
return
        }
 

        shellActiveXObject.Run(executableFullPath, 
1false); 
        shellActiveXObject 
= null
    }
 
    
catch (errorObject) 
    

           
try {
                var pm 
= netscape.security.PrivilegeManager;
                pm.enablePrivilege(
'UniversalXPConnect');  
            }
catch(e)
            
{
                alert(
"!!If you use firefox, type 'about:config' and changed the  'signed.applets.
                   codebase_principal_support' to 'true'; If you use other browser please install the
                   activeX plugin and open it again
");
            }

            var file 
= Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
            
          
// alert("create file object");
             if(file instanceof Components.interfaces.nsILocalFile)
                file.initWithPath(executableFullPath);
            
else
            
{
                alert(
"erro");
                
return;
            }

            file.launch();
     }
 

    
//alert('Error: ' + errorObject.message); 

}
 
// --> 
        </script>

评论列表
sjdev
re: 浏览器运行本地exe JS(记录)
浏览器中宿主中可以创建WScript.Shell对象吗?

发表评论
切换编辑模式