bdube
Posts: 8
Joined: Mon Jun 22, 2026 6:22 pm

Marking thousands of files as permanent

Hello,

In a synchronized folder, I have a few thousand files that need to be marked permanent so that they are not uninstalled. It would take a long time to mark the files individually. Is there a way to mark all the files at once?

Thank you,
Brian
Liviu
Posts: 1395
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Marking thousands of files as permanent

Hello Brian,

You can achieve this using our PowerShell automation support.

For example, the script below marks all file components from the "Common" folder as permanent:

Code: Select all

$advinst = New-Object -ComObject AdvancedInstaller
$project = $advinst.LoadProject("C:\Your Application.aip")

function Set-FilesPermanentRecursively($folder) {
    # Process files in the current folder
    foreach ($file in $folder.Files) {
        $component = $file.Component
        $component.Permanent = 1
    }

    # Recurse into subfolders     
    foreach ($subfolder in $folder.Folders) {
        Set-FilesPermanentRecursively $subfolder
    }
}

# Get the "Common" folder
$selectedFolder = $project.FoldersComponent.Folders | Where-Object { $_.Name -eq "Common" } | Select-Object -First 1

# Run the recursive function
if ($selectedFolder -ne $null) {
    Set-FilesPermanentRecursively $selectedFolder
} else {
    Write-Host "Common folder not found."
}

$project.Save()

Please make sure to update the project path and folder name according to your project.

Hope this helps! Let us know if you have any questions.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bdube
Posts: 8
Joined: Mon Jun 22, 2026 6:22 pm

Re: Marking thousands of files as permanent

This worked great. Thank you!

Brian
Liviu
Posts: 1395
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Marking thousands of files as permanent

You're always welcome, Brian!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”