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:

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

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

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

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:

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

10 thoughts on “Create Shortcut to Run a PS1 PowerShell File in Windows 10”

  1. This is the only way I can tile shortcut scripts with the run as administrator option selected – thankyou.
    However, it seems that using this method but then right clicking the tile, and selecting any of the ‘Tasks’ option is unsuccesfull and hangs the process, also leaving the shortcut file in use and unable to be deleted etc.

  2. This was exactly what I was looking for. Thank you! (It is amazing how many google hits suggest things that don’t work)

  3. Hello,
    I have a funny question, if you want to move the ps1 file location, do you have a way to inform the shortcup like $MyInvocation command?

  4. Thank you so much for your article. It’s a life saver. Dell didn’t provide my monitor with a shortcut for the screen orientation, but an annoying procedure through the OSD menu or the Win 10 Video Settings.

  5. Excelent info dude, it was very helpfull for me, and it is very fine explained.
    Thank you very much!!!

  6. Thanks for this…it works for me, but after my .ps1 script runs, the PowerShell window remains open, forcing the user to close it. Is there a way to get the PowerShell to exit after the script is run? Or did I do something wrong?
    Thanks

    1. the -noexit flag is what is keeping the window open.
      In the example given it keeps the window open to view the output.
      If you don’t need to see any output including error messages then you can remove the -noexit option and the window will close when it is done execution.

  7. Is it possible to edit the options when you right-click the shortcut? Because I don’t want anyone to mess around with Powershell or ISE.

Leave a Reply

Your email address will not be published.

Exit mobile version
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.