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?

4
  • 3
    Create a shortcut for powershell.exe with the arguments -File C:\path\to\script.ps1, then pin that shortcut to the task bar Commented Sep 1, 2021 at 12:02
  • 2
    That is by design, PowerShell scripts are not supposed to be able to be started using double click. Commented Sep 1, 2021 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. Commented Sep 2, 2021 at 15:31
  • @ricecrispies, the linked duplicate offers a programmatic solution that also works with paths containing spaces. Commented Nov 5, 2021 at 2:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.