How to avoid a user-based update of SNAP in a managed environment?

I’m a sysadmin at the Department of Geography at the University of Zurich and we use SNAP on our course room NUCs and on RDS for some courses.

We deploy SNAP as a PSADT package on the course infrastructure (NUCs) and on the RDS.

Because we have a defined deploy process

=> create PSADT with the latest version
=> deploy SNAP on test infrastructure with PSADT
=> the person(s) responsible for the course test the software
=> finally deploy SNAP on NUCs and RDS with PSADT

We want to set the version of SNAP and prevent users from receiving notifications about updates and being able to make updates (which are then installed in AppData of the user). Is this somehow possible?

Thank you,

Jörg

You can prevent SNAP from searching for updates by disabling all SNAP Update Centers (ToolsPlugins menu → Settings tab):

Hi Diana,

Thank you for your answer.

You may have misunderstood our approach. We have a managed environment and install SNAP on the Remote Desktop Server with a PowerShell-environment (PSADT) with no user interaction and then we update and customize the installation, also with PSADT and no user interaction.

Installation:

Execute-Process -Path "$dirFiles\esa-snap_all_windows-x64_9_0_0.exe" -Parameters "-q -varfile $dirSupportFiles/response.varfile"

Post-installation:

Execute-Process -Path "$PSHOME\powershell.exe" -Parameters "-executionpolicy bypass -File `"$dirSupportFiles\updateSnap.ps1`""

Copy-File -Path "$dirSupportFiles\snap.conf" -Destination "$envProgramFiles\snap\etc\snap.conf"
Copy-File -Path "$dirSupportFiles\snap.properties" -Destination "$envProgramFiles\snap\etc\snap.properties"

The installation directory of SNAP (e.g. C:\Program Files\SNAP) is locked for the user (student). When the user (student) updates SNAP accidentally, the update will be installed in the personal %appdata%\SNAP-folder. This causes a lot of problems, so we often suggest deleting the %appdata%\SNAP-folder to make SNAP work again for the users.

We need to have a solution to suppress the update dialog and lock SNAP to the version we have installed with the PSADT scripts. The user should not see the update dialog or be able to update SNAP.

We have the possibility to trigger a copy-job to the %appdata%-folder of the user (student) at user-login, so we may can place some kind of conf- or properties-file into the %appdata%-folder.

Atached the files: response.varfile, snap.conf, snap.properties, updateSnap.ps1

response.varfile (755 Bytes)
snap.conf (678 Bytes)
snap.properties (2.6 KB)
updateSnap.ps1 (288 Bytes)

Any news on this topic?

Sorry for the oversight — I thought I had already responded to this topic.
The Update Center settings are saved in property files specific to each of the four Update Centers. These files are created in the following location:
C:\Users\<user>\AppData\Roaming\SNAP\config\Preferences\org\netbeans\modules\autoupdate :

  • snap_community_plugins_update_center.properties
  • snap_supported_plugins_update_center.properties
  • snap_toolboxes_update_center.properties
  • snap_update_center.properties

To disable them, you need to add the following line (if it doesn’t already exist):
enabled=false

Thank you Diana,

With the exception of the ‘Update Snap’ window after starting Snap, it looks good. Is there a trick to hide this window too?

Is there a way to solve this globally without manipulating the files in every user’s folders?

This also needs some tweaking of user files:

The property
optional.version.check.onstartup.decision=no
needs to be added to
WINDOWS: <USER_DIR>\AppData\Roaming\SNAP\config\Preferences\org\esa\snap\snap\rcp.properties
LINUX: <USER_DIR>\.snap\config\Preferences\org\esa\snap\snap\rcp.properties

And add snap.versionCheck.interval=NEVER to snap.properties in <install_dir>/etc

This is a user setting so needs to be done for every user. I think there is no global switch.

I wrote a short PowerShell script to generate or update the user configuration. The idea is to execute the script with Active Setup at user login. However, if these are the only files present (if the user is new or has never started Snap before), the files will be deleted and freshly generated without the desired content.

Is there a way to tell Snap to append the other files and contents instead of deleting everything?

$folderPath = "$Env:APPDATA\SNAP\config\Preferences\org\esa\snap\snap"
if (!(Test-Path $folderPath -PathType Container)) {
    New-Item -ItemType Directory -Force -Path $folderPath | Out-Null
}
if (!(Test-Path $folderPath\rcp.properties -PathType Leaf)) {
    New-item "$folderPath\rcp.properties" | Out-Null
}
$file = Get-ChildItem "$folderPath\rcp.properties"
$filename = $file.FullName        
$b = Select-String -Quiet -Pattern "optional.version.check.onstartup.decision=no" -Path $fileName
if (-not $b)
{
   Add-Content -Path $fileName -Value "optional.version.check.onstartup.decision=no"
}


$folderPath = "$Env:APPDATA\SNAP\config\Preferences\org\netbeans\modules\autoupdate"
if (!(Test-Path $folderPath -PathType Container)) {
    New-Item -ItemType Directory -Force -Path $folderPath | Out-Null
}
("snap_community_plugins_update_center.properties","snap_supported_plugins_update_center.properties", "snap_toolboxes_update_center.properties", "snap_update_center.properties") | foreach {
  if (!(Test-Path $folderPath\$_ -PathType Leaf)) {
    New-item "$folderPath\$_" | Out-Null
  }
}
$files = Get-ChildItem "$Env:APPDATA\SNAP\config\Preferences\org\netbeans\modules\autoupdate\*.properties" -Exclude ui.properties
for ($i=0; $i -lt $files.Count; $i++) 
{ 
  $filename = $files[$i].FullName        
  $b = Select-String -Quiet -Pattern "enabled=false" -Path $fileName
  if (-not $b)
  {
     Add-Content -Path $fileName -Value "enabled=false"
  }
}

I fear not.
SNAP generates some files on first start, but I think it there is no way to tell SNAP to append the contents.
But there must be away how SNAP detects if it needs to create the files. Otherwise, they would be recreated with every start. But I don’t know how this is done. Sorry.
Maybe, @diana_harosa or @TomBlock can help.

Thank you, I hope a solution can be found. I am close to a pretty perfect solution for Snap for educational environments.

Okay, I got it working in the following way:

  • delete the $Env:APPDATA\SNAP and start SNAP to create a proper base to work with
  • from this folder, add the config-dir and .lastUsedVersion to a zip-File
  • deploy the content of the zip-file to a folder on the destination-server
  • create the following addUserProperties.ps1
$roamingPath = "$Env:APPDATA\SNAP"

if (!(Test-Path $roamingPath -PathType Container)) {
    Copy-Item C:\PSADT\SNAP\SNAP -Destination $Env:APPDATA -Recurse
} else {
    #
    # rcp.properties (update-window at startup)
    #
    $folderPath = "$roamingPath\config\Preferences\org\esa\snap\snap"
    if (!(Test-Path $folderPath -PathType Container)) {
        New-Item -ItemType Directory -Force -Path $folderPath | Out-Null
    }
    if (!(Test-Path $folderPath\rcp.properties -PathType Leaf)) {
        New-item "$folderPath\rcp.properties" | Out-Null
    }
    $fileName = (Get-ChildItem "$folderPath\rcp.properties").FullName
    $pattern = Select-String -Quiet -Pattern "optional.version.check.onstartup.decision=no" -Path $fileName
    if (-not $pattern)
    {
       Add-Content -Path $fileName -Value "optional.version.check.onstartup.decision=no"
    }
    $folderPath = "$roamingPath\config\Preferences\org\netbeans\modules\autoupdate"
    if (!(Test-Path $folderPath -PathType Container)) {
        New-Item -ItemType Directory -Force -Path $folderPath | Out-Null
    }
    #
    # Possible properties-Files
    #
    # snap_community_plugins_update_center.properties
    # snap_supported_plugins_update_center.properties
    # snap_toolboxes_update_center.properties
    # snap_update_center.properties
    #
    $propertyFiles = @("snap_update_center.properties")
    $propertyFiles | foreach {
        if (!(Test-Path $folderPath\$_ -PathType Leaf)) {
            New-item "$folderPath\$_" | Out-Null
        }
        $fileName = (Get-ChildItem "$folderPath\$_").FullName
        $pattern = Select-String -Quiet -Pattern "enabled=false" -Path $fileName
        if (-not $pattern) {
            Add-Content -Path $fileName -Value "enabled=false"
        }
    }
}
  • create an active-setup entry (example for PSADT)
        Set-ActiveSetup -ExecuteForCurrentUser $true -StubExePath "$PSADTFiles\addUserProperties.ps1" -Arguments "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden" `
          -Description 'PSADT SNAP 12.0' `
          -Key 'PSADT_SNAP_12.0' `
          -ContinueOnError $true

The addUserProperties.ps1 respects und updates exisiting profiles or adds a minimal skeleton, if the user is new or newer started SNAP before.

I hope this helps other users with similar problems.

1 Like