Link to home
Start Free TrialLog in
Avatar of lword
lword

asked on

BrowseForFolder() raising Permission denied error in XP Internet Explorer

function fnGetMyPathJ(formObj)
{
      var oShell = new ActiveXObject("Shell.Application");
      var oFolder = new Object;                        
      oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
      if(oFolder!= null)
      {
            var oFolderItem = new Object;          
            oFolderItem = oFolder.Items().Item();
            pathValue =oFolderItem.Path;
            folder_remotePath  =pathValue;

                  var fso = new ActiveXObject("Scripting.FileSystemObject");

                  var WshNetwork = new ActiveXObject("WScript.Network");
                  var oDrives =new Object;
                  oDrives = WshNetwork.EnumNetworkDrives();
                  alert(3);

                  for(i=0;i<oDrives.length-1;i=i+2)
                  {
                        if (oDrives.Item(i) == fso.GetDriveName(fso.GetAbsolutePathName(pathValue)))
                        {
                              alert(oDrives.Item(i+1));
                              remotePath= oDrives.Item(i+1);
                              drivePath= oDrives.Item(i);
                              folderPath=oFolderItem.Path;
                              folder_remotePath=folderPath.replace(drivePath,remotePath);
                        }
                        
                  }
            
            document.getElementById(formObj).value=folder_remotePath;
      }
}
My OS is XP. The above code is working in visual interdev but not in IE . It is raising PERMISSION DENIED error. In 2000 it is working fine.
ASKER CERTIFIED SOLUTION
Avatar of ClickCentric
ClickCentric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lword
lword

ASKER

Its because of security.

To over come this please do the following
Go to Internet options->security Tab->Custom level->Initialise and script activeX control not marked as safe: Enable


Lword