Logoffcleanup PowerShell Script Opening in Notepad
  • 01 Jun 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Logoffcleanup PowerShell Script Opening in Notepad

  • Dark
    Light
  • PDF

Article summary

Logoffcleanup PowerShell Script Opening in Notepad

PROBLEM BEHAVIOR

When configured to launch a PowerShell script in the registry, the script is opened in Notepad when a user logs out of XA:

[HKEY_LOCAL_MACHINE\Software\HealthCast\eXactACCESS\LogoffCleanup Settings\LogoffScript\MyScript.ps1]
"Path"="C:\Program Files (x86)\HealthCast\eXactACCESS\wrappers\xaLogoffCleanup\"

EXPECTED BEHAVIOR

The PowerShell script should run (and not open in Notepad) when a user logs out of XA.

OTHER BEHAVIOR

If you double-click the PowerShell script file, it also opens in Notepad.

AFFECTS:

All versions of XA running on Windows 10.

ROOT CAUSE: Security Behavior in Windows 10

Windows 10 sets the default app for PS1 files to Notepad rather than PowerShell, as a security precaution (to prevent the accidental running of a malicious script).

RESOLUTION

  1. In Windows, change the default program for opening PowerShell scripts to PowerShell (most customers will be unwilling to do this).
  2. Rather than running a script file, run PowerShell and pass the script name as a parameter:

[HKEY_LOCAL_MACHINE\SOFTWARE\HealthCast\eXactACCESS\LogoffCleanup Settings\LogoffScript\powershell.exe]
Path=C:\Windows\System32\WindowsPowerShell\v1.0\
Param=-executionPolicy bypass -WindowStyle Hidden -file \"C:\Program Files (x86)\HealthCast\eXactACCESS\wrappers\xaLogoffCleanup\MyScript.ps1"


Was this article helpful?