Keith Joubert logo - home.

Home
Contact

Binary Search
Sort Multiple Columns
Filing Functions
Extracting Excel data
Read and Write .csv files
Show Progress Messages
Send Automatic Email
Running under .hta
Setting Folder Attributes
Long-script warnings
Desktop Shortcut


 

 
SETTING  FOLDER  ATTRIBUTES

You may encouter a lot of difficult-to-trace and varying error reports when running on Windows XP and Server - faults that did not arise when running on your development system. 

This can be due to idiosyncrasies of the system, and not due to your programming.  

With XP and Server the Read-only Attribute can not be permanently changed by Windows Explorer. 

This is a "By-Design" bug in Microsoft's XP and Server system, in that folders default to Read-Only on creation.  This results in problems with writing-to and deleting files and sub-folders.  Even when NTFS drive permissions are set to Full Control, a Windows Explorer clearing of Read-only reverts to Read-only after one iteration.

Note: the authorised users should have their NTFS permissions on the server drive set to Modify with added Delete permission, as a minimum.

Your application should set the attributes to System Fles on folder creation.  However, if that has not been done and should you experience strange error messages during program operation, suspect the Folder attribute settings and act as follows:

Microsoft has issued several advisories regarding this problem, of which Article ID 326549, of the 8th Jan 2008,  is useful:  http://support.microsoft.com/?kbid=326549    Microsoft states that this bug applies to Vista, too, but the Vista systems on which my application has run did not exhibit such behaviour.  Nevertheless, the bug fix can be applied to Vista folders without ill effects.

The attributes can be set to 'System' files with a command line:

Click Start, click Run, type cmd, and then press Enter.

Type  Attrib -r +s  drive:\<path>\<foldername>

In a typical case perform this action on the following folders: 
Attrib -r +s  W:\XXX  (assuming your server drive letter is 'W').
Attrib -r +s  C:\XXX\Sub-folder
Attrib -r +s  C:\XXX   // another folder, etc

Your application should set the attributes of the Ram disk Folders on creation.

Note: As an alternative to command-line attribute setting, you can use the Clear-Read-Only application available free from Crispy Bytes.

In the developed application, the setup program included code to set the folder attributes.  In the case of the Ram Drive, which is, of course, deleted on shut-down, the folder attribute was set on initially loading the folders.  Typical code is shown below:

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

   function CopyFolder(FromFolder,ToFolder,overwrite) {
        //Copies a file  JScript 3.0+    Set overwrite to true or false;
       var f = fso.GetFolder(FromFolder);
       f.Copy(ToFolder,overwrite);
   }

   function InitOps(){
      var fro = "C:\\ZZZ\\XXXXXXXXX";  // Italics = your choice.
      var des, newfolder = "";
      des = "R:\\TTT";
      if (!fso.FolderExists(des)) {
         newfolder = fso.CreateFolder(des);
         var fold=fso.GetFolder(des);
         fold.attributes=4;  // Note '4' means System File - this works for XP, Server, Vista
         des = "R:\\TTT\\Program";
         newfolder = fso.CreateFolder(des);
         var fold=fso.GetFolder(des);
         fold.attributes=4;
         des = "R:\\TTT\\Program";
         CopyFolder(fro,des,true);  // See filing for this function.
      }
   }

TopTop