Enable Silverlight Plugin (NPAPI) in Chrome using registry key fix -


i have created powershell script add npapi , silverlight* registry keys enable silverlight in google chrome. powershell script works fine , adds 2 registry keys, silverlight plugin still disabled in chrome , when load silverlight based sites “install silverlight” popup. have restarted machine , still silverlight plugin disabled.

however, if go registry , delete npapi , silverlight* registry keys , re-create them (string value - reg_sz), when reload page in chrome, silverlight enabled , site loads perfectly. don’t understand what’s going on.

the powershell script creates these keys when delete them , re-create them manually take effect , silverlight plugin enabled. if go chrome://plugins, chrome reports silverlight plugin “enabled enterprise policy”. have run script on machine , exact same thing happens. has else experienced , know fix or doing wrong?

powershell script used create npapi , silverlight* registry keys:

function create-path {      [cmdletbinding()]     param (         [parameter(valuefrompipeline = $false, mandatory = $true)]         [string]$path          ,         [parameter(valuefrompipeline = $true, mandatory = $false)]         [switch]$overwriteifexists     )     process {         if(($overwriteifexists.ispresent) -or (-not (test-path $path))) {             new-item $path -force | out-null         }     } }  function get-registrykeywithvalue {      [cmdletbinding()]     param (         [parameter(valuefrompipeline = $false, mandatory = $true)]         [string]$path          ,         [parameter(valuefrompipeline = $true, mandatory = $true)]         [string]$value     )     process {         $properties = get-item $path | select -expandproperty property         $properties | %{             $property = get-itemproperty -path $path -name $_             if ($property.$_ -eq $value) {                 write-output $property             }         }     } } function get-nextkeyinpath {      [cmdletbinding()]     param (         [parameter(valuefrompipeline = $false, mandatory = $true)]         [string]$path      )     process {         try {             write-output ((get-item $path -erroraction stop | select -expandproperty property | measure-object -maximum).maximum + 1) | out-string         } catch {             write-output "1"                 }     } } function create-chromeenabledpluginpolicy {      [cmdletbinding()]     param (         [parameter(valuefrompipeline = $true, mandatory = $true)]         [string]$value     )     begin {         $chromepluginpolicypath = "hklm:\software\policies\google\chrome\enabledplugins"         create-path $chromepluginpolicypath     }     process {         if (-not (get-registrykeywithvalue -path $chromepluginpolicypath -value $value)) {             $keyname = get-nextkeyinpath -path $chromepluginpolicypath              new-itemproperty -path $chromepluginpolicypath -name $keyname -value $value -propertytype string          }     } }  "npapi", "silverlight*" | create-chromeenabledpluginpolicy  

the code:

process {     try {         write-output ((get-item $path -erroraction stop | select -expandproperty property | measure-object -maximum).maximum + 1) | out-string     } catch {         write-output "1"             } } 

seems return more single string. amending following resolves issue:

process {     try {         [int]$i = ((get-item $path -erroraction stop | select -expandproperty property | measure-object -maximum).maximum + 1)         write-output ([string]$i)     } catch {         write-output "1"             } } 

a simplified demo of issue & solution:

  • run following code: new-itemproperty -path 'hklm:\software\johnlbevan' -name (1 | out-string) -propertytype string -value 'test'
  • now open regedit , create key name 1; succeeds (i.e. have 2 keys called 1; control/non displayable character being added in our ps script).
  • if try add third key called 1 using either method (regedit or powershell) you'll error due key name existing (showing there unique check in place; it's our original 1s aren't unique)
  • if try either of following code snippets, things work expected:
    • new-itemproperty -path'hklm:\software\johnlbevan' -name "1" -propertytype string -value 'test'
    • new-itemproperty -path'hklm:\software\johnlbevan' -name [string]1 -propertytype string -value 'test'

(disclosure: work @jwoods83, had advantage of seeing issue / playing directly)


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -