title: Running VBScript from PowerShell without "File Open - Security Warning"
body: <p>I'm running a VBScript from a PowerShell script in an attempt to automate component registrations. </p>
  
  <p>My function looks like this:</p>
  
  <pre><code>function Register-NaviLink ($vbsPath, $vbsName) {
      # Run register.vbs
      $register=$vbsPath+"\"+$vbsName
      Start-Process $register
  }
  </code></pre>
  
  <p>This works OK (it runs the VBScript) but, as the purpose of the PowerShell script is to achieve automation of the process, I'd rather not be confronted with a "File Open - Security Warning" dialog when the VBScript fires.</p>
  
  <p>In an attempt to work around this issue, I created a new registry key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Associations" with value name "LowRiskFileTypes" and data ".vbs". After reboot, the PowerShell script could run the VBScript without the warning dialog.</p>
  
  <p>However, thinking that leaving the new registry key in place permanently would present a security risk from malicious .vbs scripts, I tried to incorporate the creation and deletion of the registry key into my PowerShell script as follows:</p>
  
  <pre><code>function Register-NaviLink ($vbsPath, $vbsName) {
      $workingDirectory=pwd
      $registryKey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Associations"
      $registryKeyName="LowRiskFileTypes"
      $registryKeyValue=".vbs"
  
      Set-Location HKCU:
      if(-not(Test-Path ($registryKey))) {
          New-Item -Path $registryKey
          New-ItemProperty -Path $registryKey -Name $registryKeyName -Value $registryKeyValue
      }
  
      $register=$vbsPath+"\"+$vbsName
      Start-Process $register
  
      Remove-Item -Path $registryKey -force
      Set-Location $workingDirectory
  }
  </code></pre>
  
  <p>The PS script runs OK (no errors) but the creation and deletion of the registry key seems to have no effect on the security warning dialog without a reboot.</p>
  
  <p>Is it possible to refresh the registry keys without reboot?</p>
  
  <p>If  so, can this be done through PowerShell scripting?</p>