formspowershellwinformsmonthcalendar

Why does my System Windows Form look different when the .ps1 file is run from a shortcut?


I'm using Windows.Forms.MonthCalendar from the System.Windows.Forms assembly.

When running the script from Powershell ISE, it looks like this: enter image description here

But when running the script via a dekstop shortcut, it looks like this: (Shortcut target: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "C:\Temp\Test.ps1") enter image description here

If Powershell ISE is using a later version of Powershell, how can I use that version in my shortcut?

TIA


Solution

  • Needed to add the following before creating the form:

    [System.Windows.Forms.Application]::EnableVisualStyles();