Steve Shannon

How do I set a folder to Hidden

Thu May 05, 2005 1:01 am

Can anyone help?

I need to set a number of folders included in my install as hidden. I cannot see anyway to do this.

Any help would be appreciated.

Thanks

Cata
Posts: 638
Joined: Thu Apr 10, 2003 7:37 am
Contact:  Website

Thu May 05, 2005 2:22 pm

The only way to do that is by a custom action. Windows Installer does not support attributes for folders, only for files.
Catalin Rotaru - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact:  Website

Thu Nov 24, 2005 10:17 am

Hi,

Here is an example of a VBScript that sets the Hidden attribute for the Application Folder.

Code: Select all

Function MakeFolderHidden()
   Dim filespec
   filespec = Session.property("APPDIR")

   Dim fso, folder
   Set fso = CreateObject("Scripting.FileSystemObject")

   Set folder = fso.GetFolder(filespec)
   folder.attributes = folder.attributes Or 2
End Function
This custom action should be of immediate type, otherwise the installer cannot access the APPDIR property.

It also should be scheduled at a time the folder has been created already. The InstallFinalize standard action is such a place.

Note: If you are using a version older than 3.4 replace APPDIR with TARGETDIR in the above script.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com

toyito
Posts: 5
Joined: Sun Dec 04, 2005 4:55 am

Fri Dec 23, 2005 3:47 pm

Hi
Im really interested in use this script bu i dont kwon how, woul u give more details pls

Hector

Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact:  Website

Sat Dec 24, 2005 9:08 pm

Hi,

Follow the steps below:

1. Create a new text file ("MakeFolderHidden.vbs") and copy the above function into it.

2. Switch to the Custom Actions page and select from the toolbar "Show Standard Action -> Before Finalization -> InstallFinalize".

3. Right click the "InstallFinalize" item and select "New Attached Custom Action", then choose the script file you created in step 1.

4. In the "Function Name" field enter "MakeFolderHidden" (without quotes).

5. Set the Execution Condition appropriately. For example, if the script should run when the application is installed, set the Execution Condition to: (NOT Installed)

6. This VBScript sets the Hidden attribute for the Application Folder. Thus, if you need to hide another folder, you should modify the script accordingly.

Regards,
Denis
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/

HasNoName
Posts: 5
Joined: Fri Aug 16, 2013 1:17 am

Re: How do I set a folder to Hidden

Fri Aug 16, 2013 1:26 am

Hello,

I hope anyone can help me :)
I tried this one in the new version of AI, but it wouldn't work :roll:
I need the attribute "Read Only" instead "Hidden" because I will integrate icons in folders that includes desktop.ini, desktop.ico and I wouldn't use a batch.

What steps are required?

I use the script above. Support the newest OS this variant of VBS?

Thank you in advance :)
_

Teodor
Posts: 73
Joined: Thu Jul 25, 2013 9:56 am

How do I set a folder to Hidden

Fri Aug 16, 2013 11:41 am

Hello
I need the attribute "Read Only" instead "Hidden" because I will integrate icons in folders that includes desktop.ini, desktop.ico and I wouldn't use a batch.
You can use the same VB script and change only the folder attribute code to 1 for Read Only.
What steps are required?
You can add an Execute inline script code custom action with sequence with the following properties:
- Action Data: [APPDIR]
- Script Type: Visual Basic script (*.vbs)
- Execution Time: When the system is being modified (deferred)
- Execution Options: check all (no impersonation)
- Execution Stage Condition: Install [x]
- Script Code:

Code: Select all

Dim filespec
filespec = Session.property("CustomActionData")

Dim fso, folder
Set fso = CreateObject("Scripting.FileSystemObject")

Set folder = fso.GetFolder(filespec)
folder.attributes = folder.attributes Or 2
Last step is to move the MakeFolderHidden custom action under Install Execution Stage just before Finish Execution action group.
I use the script above. Support the newest OS this variant of VBS?
I've attached a project sample with the MakeFolderHidden custom action.
AI f545 sample.zip
(2.73KiB)Downloaded 961 times
This project was tested successfully on Windows 8.

Best regards
Last edited by Teodor on Fri Aug 16, 2013 1:53 pm, edited 1 time in total.
Teodor Micu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

HasNoName
Posts: 5
Joined: Fri Aug 16, 2013 1:17 am

Re: How do I set a folder to Hidden

Fri Aug 16, 2013 1:43 pm

Thank you, it works very fine :) 8-)

Can per script added more attributes? (read, hidden, ...)

But why read only instead system for folder icons?
_

Teodor
Posts: 73
Joined: Thu Jul 25, 2013 9:56 am

Re: How do I set a folder to Hidden

Fri Aug 16, 2013 1:55 pm

Hello
Can per script added more attributes? (read, hidden, ...)
Of course, you can set multiple attributes with the same VB script like this:

Code: Select all

folder.attributes = folder.attributes Or 1 Or 2 Or 4
This example will set three attributes: Read Only, Hidden, System.
But why read only instead system for folder icons?
I'm afraid I don't understand your question. Can you give more details about what you want to achieve?

Best regards
Teodor Micu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

HasNoName
Posts: 5
Joined: Fri Aug 16, 2013 1:17 am

Re: How do I set a folder to Hidden

Fri Aug 16, 2013 3:23 pm

Hello,
M.Teodor wrote:
Can per script added more attributes? (read, hidden, ...)
Of course, you can set multiple attributes with the same VB script like this:

Code: Select all

folder.attributes = folder.attributes Or 1 Or 2 Or 4
This example will set three attributes: Read Only, Hidden, System.
OK, thank you.
But why read only instead system for folder icons?
I'm afraid I don't understand your question. Can you give more details about what you want to achieve?
I mean, why does this works only with Read Only attribute and not with System attribute to see the folder icons and some information of desktop.ini? :) I mean, many years ago, this was still working with the system attributes in Windows :?

A question. How can I set a file attribute e.x. desktop.ini file that was imported in AI?
_

Teodor
Posts: 73
Joined: Thu Jul 25, 2013 9:56 am

Re: How do I set a folder to Hidden

Tue Aug 20, 2013 8:07 am

Hi
I mean, why does this works only with Read Only attribute and not with System attribute to see the folder icons and some information of desktop.ini?
I'm afraid it's unclear what you mean by "this". Maybe the article How to Customize Folders with Desktop.ini could help you.
A question. How can I set a file attribute e.x. desktop.ini file that was imported in AI?
Windows Installer has support for setting properties on files. In Advanced Installer go to Files and Folders page, select the file(s), press ENTER and from the File Properties Tab and select the file(s) attributes.

Let us know if you have other questions.

Best regards
Teodor Micu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

dsadsadsa
Posts: 1
Joined: Fri Oct 08, 2021 8:07 pm

Re: How do I set a folder to Hidden

Fri Oct 08, 2021 8:12 pm

Hello,

I've foud this topic.
It's a little bit old, but I'll try.

I have to hide 2 folders added in the system during an installation.
I have used the script here above to test with one folder and it's working like a charm.

Now that I would like to hide also the second one I don't know how to do it.
I've tried to add another script with the name of the second folder ( plus the "_dir")

But it's not working at all.

Anyone could help me, please?

Thank you in advance

Catalin
Posts: 6509
Joined: Wed Jun 13, 2018 7:49 am

Re: How do I set a folder to Hidden

Mon Oct 11, 2021 2:49 pm

Hello and welcome to our forums,

In order to achieve what you want, we can proceed as it follows:

Code: Select all

Dim filespec
filespec = Session.property("CustomActionData")

Dim fso, folder
Set fso = CreateObject("Scripting.FileSystemObject")

Dim dataArray

dataArray = split (filespec, "|")

for each x in dataArray
Set folder = fso.GetFolder(x)
folder.attributes = folder.attributes Or 2
Next
Where the "Custom Action Data" field looks like this:

Code: Select all

[APPDIR]|[test_Dir]
The above script should set the hiddent attribute for both APPDIR & test folders.
test_Dir.png
test_Dir.png (75.66KiB)Viewed 18506 times

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”