Based on the certain request , I have hide specific folder through script which is given below...
On error resume next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("Folder path")
If objFolder.Attributes = objFolder.Attributes AND 2 Then
objFolder.Attributes = objFolder.Attributes XOR 2
Now I need to revert the case ( UNHIDE ).
Kindly suggest what modification I need to do in the scritp as i am not getting proper clue to get this rectified.
Here is the slow burn to how this works.
Start by not using On Error because it will only hide you mistakes.
Run this a few times until you understand what is happening.
Const BIT1 = 2 folder = "c:\temp" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(folder) mask = objFolder.Attributes If mask And BIT1 Then MsgBox "Folder is hidden: 0x" & Hex(mask) ' unhide newmask = mask Xor BIT1 MsgBox "NEWMASK IS: 0x" & Hex(newmask) objFolder.Attributes = newmask Else MsgBox "Folder is NOT hidden: 0x" & Hex(mask) newmask = mask Or BIT1 MsgBox "NEWMASK IS: 0x" & Hex(newmask) objFolder.Attributes = newmask End If
- Edited by jrv Thursday, January 02, 2014 3:59 PM
Sorry - I pasted before I had converted all of the pieces. I fixed.
"Or" and "Xor" are use to twiddle the bits on or off against a mask. "And" is used to test against a mask. "BIT1" is the mask for the bit we are interested in.
This can be generalized as a function that toggles a bit or as a function that toggles a set of bits.