# This script works through GFI RMM to fix a common issue installing # Managed Antivirus. If you get the error message: # Product: Managed Antivirus -- Error 1606. Could not access network location %APPDATA%\. # This script fixes a faulty registry entry that has # HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData # Set to %APPDATA% instead of %USERPROFILE%\AppData\Roaming $majorVersion=[System.Environment]::OSVersion.Version.Major if ($majorVersion -eq 5) { # We're dealing with XP write-host "This script doesn't support Windows XP." exit 1001 } # Get the registry value without expanding the environment variables $Key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders") $Value = $Key.GetValue("AppData",$False, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames) if ($Value -ne '%USERPROFILE%\AppData\Roaming') { # Need to fix the registry entry Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name AppData -Value %USERPROFILE%\AppData\Roaming -Type ExpandString -Force write-host "Fixing the bad registry entry." exit 1002 } else { write-host "No problem found." } exit 0