Create Shortcut to Run a PS1 PowerShell File in Windows 10

PowerShell is an advanced form of command prompt. It is extended with a huge set of ready-to-use cmdlets and comes with the ability to use .NET framework/C# in various scenarios. When you double-click on a *.ps1 script file, it opens in Notepad or other app associated with this file type. Sometimes it can be very useful to create a shortcut to run your PS1 script file directly.

By default, Windows comes with a context menu command 'Run with PowerShell', which is available for PS1 files. However, if your script has no user input and doesn't include a pause at the end, the PowerShell output will disappear quickly. Another issue is the default execution policy which may prevent your script from being started from the context menu. By following the instructions below, you will be able to create a shortcut for your PS1 file and simply run it by double-clicking on the shortcut. This is very convenient and time saving.

In this article, I will use the following PS1 file as an example:

Windows 10 PowerShell File Contents

To create a shortcut for a PS1 PowerShell file in Windows 10, do the following.

  1. Copy the full path to your PS1 script file.
  2. Right click the empty space on your Desktop. Select New - Shortcut from the context menu (see the screenshot).
  3. In the shortcut target box, type the following:
    powershell.exe -noexit -ExecutionPolicy Bypass -File
  4. Now, paste the path to your script file. You will get something like this:
    powershell.exe -noexit -ExecutionPolicy Bypass -File c:\data\winaero\winaero.ps1

    Windows 10 Create PowerShell Script Shortcut

  5. Give your shortcut some meaningful name. You can use any name you want. Click on the Finish button when done.
    Any Name Shortcut Windows 10

You are done. Double-click on the shortcut to run your script.

Windows 10 PowerShell Script Shortcut In Action

Now, you can move this shortcut to any convenient location, pin it to taskbar or to Start, add to All apps or add to Quick Launch (see how to enable Quick Launch). You can also assign a global hotkey to your shortcut.

Articles of interest:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.