Jump to content

Add PowerShell file (*.ps1) to New Context Menu of File Explorer


Jordan

Recommended Posts

Add PowerShell file (*.ps1) to New Context Menu of File Explorer

 

In this article, we will see how to get a useful context menu item to create a New -> Windows PowerShell script. It will save you time if you need to create them from time to time. You get a new file with the PS1 extension instantly with one click.

Usually, to create a PowerShell file, you can either create a new text file and rename its extension every single time to .ps1, or you can use Notepad. Using Notepad, it is possible to save the entered text as a powershell file by selecting the File - Save menu item and typing the filename with the ps1 extension in quotes. It is necessary to add quotes to save it with the correct extension. Another option is the app Windows PowerShell ISE, which starts very slow, but can save your scripts directly to .ps1 files.

Instead, the New -> Windows PowerShell script menu item is more useful. To get it working, apply the following simple Registry tweak.

 

Open Registry Editor.

Go to the following Registry key:

HKEY_CLASSES_ROOT\.ps1

Tip: You can access any desired Registry key with one click.

Create a new subkey here named "ShellNew". You will get

HKEY_CLASSES_ROOT\.ps1\ShellNew

Create new ShellNew

 

Create new ShellNew 2

 

Under the ShellNew subkey, create a new string value named NullFile. Don't set its value data, leave it empty. This value indicates that Windows should create an empty file without

any content.

Create NullFile parameter

 

Now, open the context menu of any folder. You can just right click the empty space on your Desktop. It will have a new item in the "New" context menu: New Windows PowerShell Script

 

Once you click it, a new empty *.ps1 file will be created:

New Windows PowerShell Script 2

 

The next time you need to create a PowerShell script file, you can use this context menu item to save your time.

I made ready-to-use Registry files, so you can avoid manual Registry editing. An undo file is also included.

 

Download Registry files

 

That's it. This tricks works in Windows 7, Windows 8 and Windows 10. It should work in older Windows versions too.

 

SOURCE

Link to comment
Share on other sites


  • Views 976
  • Created
  • Last Reply

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...