0

I have written a very simple PowerShell script called "open backup.ps1". It just goes: start ms-settings:backup

When I run it from the Powershell ISE or choose "Run with PowerShell" in Windows Explorer, it executes successfully and opens the backup settings, but when I run it by double-clicking it or by choosing "open with" and then PowerShell, it fails to do what it is supposed to.

How do I get it so that it will run correctly by default in Windows, and especially when it is pinned to the taskbar, which is where I want to keep the script?

  • 3
    Create a shortcut for powershell.exe with the arguments `-File C:\path\to\script.ps1`, then pin that shortcut to the task bar – Mathias R. Jessen Sep 01 '21 at 12:02
  • 2
    That is by design, PowerShell scripts are not supposed to be able to be started using double click. – Dennis Sep 01 '21 at 12:51
  • 1
    I tried what you said, but it didn't work. Then finally I worked it out. The problem was simply that for some reason, Windows will not run a PowerShell script with a space in its name, even if I enclosed the path and name within quotes. I changed the file name to mssettingsdisplay.ps1 and now it works. – ricecrispies Sep 02 '21 at 15:31
  • @ricecrispies, the linked duplicate offers a _programmatic_ solution that also works with paths _containing spaces_. – mklement0 Nov 05 '21 at 02:21

0 Answers0