title: Adding path permanently to windows using powershell doesn't appear to work
body: <p>I followed <a href="https://codingbee.net/powershell/powershell-make-a-permanent-change-to-the-path-environment-variable" rel="nofollow noreferrer">this procedure</a> in order to permanently add a path to SumatraPDF using powershell. The last few commands from the link are meant to check that the path has indeed been added.</p>
  <p>When I access the path using the following command,</p>
  <pre><code>(get-itemproperty -path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path.split(';')
  </code></pre>
  <p>the result includes the path to SumatraPDF</p>
  <pre><code>C:\Windows\system32
  C:\Windows
  C:\Windows\System32\Wbem
  C:\Windows\System32\WindowsPowerShell\v1.0\
  C:\Windows\System32\OpenSSH\
  C:\ProgramData\chocolatey\bin
  C:\texlive\2021\bin\win32
  C:\Users\921479\AppData\Local\SumatraPDF
  </code></pre>
  <p>However when I access it using the following command,</p>
  <pre><code>($env:path).split(';')
  </code></pre>
  <p>the result does not contain the path to SumatraPDF:</p>
  <pre><code>C:\Windows\system32
  C:\Windows
  C:\Windows\System32\Wbem
  C:\Windows\System32\WindowsPowerShell\v1.0\
  C:\Windows\System32\OpenSSH\
  C:\ProgramData\chocolatey\bin
  C:\texlive\2021\bin\win32
  C:\Users\921479\AppData\Local\Microsoft\WindowsApps
  </code></pre>
  <p>Finally, actually passing <code>sumatrapdf</code> does not works, which indicates to me that the real path is the one accessed using the <code>get-itemproperty</code> command.</p>
  <p>Why does the path set in the registry not correspond to the one set in <code>$env:path</code>? Is there a mistake in the procedure shown in the <a href="https://codingbee.net/powershell/powershell-make-a-permanent-change-to-the-path-environment-variable" rel="nofollow noreferrer">link</a> I followed? How can I correct it?</p>
  <p>I should mention I have already tried restarting the shell but it doesn't help.</p>