Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: How to run PowerShell scripts easily from start menu

18 Mar 2015   #1

Windows 7 Pro x64
How to run PowerShell scripts easily from start menu

Hi, I have a very big problem

I put 2 scripts in C:\Windows (pong.ps1 and pung.bat).
And I added ".PS1" in the PathExt environment variable.

But :
  • When I clic Start button, and type pung, my batch script pung.bat appears in the Programs list and is selected so I just need to press [Enter] to run it (this is cool )
  • But when I clic Start button, and type pong, my powershell script pong.ps1 doesn't appears in the Programs list. I have to type pong.ps1 (so it's a little bit longer for me )

Can anybody help me to be faster ?! Please

My System SpecsSystem Spec
18 Mar 2015   #2

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

Hello Surfin, and welcome to SevenForums,

Mmm, that's a very big problem indeed. Two simple steps will help that:

1) Create a Shortcut of this pong.ps1 file. (The name of this Shortcut should match the name of the target file.)
2) Place this new Shortcut in C:\Users\%Username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs (or C:\ProgramData\Microsoft\Windows\Start Menu\Programs).

The PATHEXT environment variable only serves a purpose within the command line. It is not used anywhere else.
My System SpecsSystem Spec
18 Mar 2015   #3

Windows 7 Pro x64

Thanks for this answer
But I forgot to tell that I want to copy a lot of PowerShell scripts in C:\Windows so it will be difficult to create a shortcut for every one
My System SpecsSystem Spec

19 Mar 2015   #4

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

No task be too difficult when the power of PowerShell is on our side.

Attached is a PowerShell script that will automate the creation of Shortcut files for you.

Simply run the PowerShell script once you have placed all desired .ps1 files in C:\Windows.

# Make Shortcuts of select files residing in $source_location at $destination_location

[string] $source_location = "C:\Windows"
[array]  $file_masks = "*.ps1"
[string] $destination_location = "C:\Users\$env:USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\PowerShellProgs"

[array]$files = Get-ChildItem -Path ( "$source_location" + '\*' ) -Include $file_masks -ea 0
if (!$?) {'Error: ' + "$($error[0].Exception.Message)"; Start-Sleep 2; exit 1 }

if (!(Test-Path $destination_location -PathType container)) { 'The destination path ' + """$destination_location""" + ' does not exist. It will be created.' ; New-Item $destination_location -ItemType container >$null}

$shell = New-Object -ComObject 'WScript.Shell'
foreach ($file in $files) {
    $lnk = $shell.CreateShortcut( "$( Join-Path $destination_location $(Split-Path -Leaf $($file.FullName)))" + ".lnk" )
    $lnk.TargetPath = $file.FullName
    $lnk.WorkingDirectory = Split-Path -Parent $file.FullName

Start-Sleep 2
exit 0

Attached Files
File Type: ps1 th-364505.ps1 (1.0 KB, 1 views)
My System SpecsSystem Spec
19 Mar 2015   #5

Windows 7 Pro x64

Wow ! Nice workaround ! Thank you...

I will use it, but I'm still frustrated that the PS1 files are not as easy to call as batch files with the Run dialog (Win+R)

If ever someone find another workaround, I would be VERY happy
My System SpecsSystem Spec
19 Mar 2015   #6

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

Unfortunately, I don't think there is such a workaround for allowing the functionality of running a file without typing it's extension into the Run dialog.

The only file types where you are able to omit the file extension for, in the Run dialog, are strictly limited to, *.exe, *.pif, *.com, *.bat and *.cmd.
My System SpecsSystem Spec

 How to run PowerShell scripts easily from start menu

Thread Tools

Similar help and support threads
Thread Forum
Help me integrate a Powershell script into the context menu
Hi all, I want to add a custom entry to the right-click context menu so that I can send a copy of a file to a predetermined folder on a remote computer. This idea is based on a tutorial. I stored a Powershell script in C:\context-menu.ps1. There should only be one argument (which is the file's...
General Discussion
Powershell start-process with -wait while running as administrator
I need to be able to start a process and have it wait for the process to complete. For example, if I run the below: start-process notepad -wait ::Show("Started running.") Notepad opens, and after I close it the message box pops up. This is exactly what I want to see except that the process I...
General Discussion
Web Cam Unable To Start Easily (DELL INSPIRON 1564 WINDOWS 7)
Hi, Eveyone as the title says. Why does it takes too long to start web cam from web cam central,i have to adjust the screen lid multiple times,and always need to press web cam portion. I had removed the lid frame,to check the web cam,for looseness,but everything looks normal. I don't...
Hardware & Devices
Start Menu - Add Libraries to Search in Start Menu
How to Pin Libraries to Search and See More Results in Start Menu This tutorial will show you how to add links for the Libraries in the Start Menu, to be able to search from the Start Menu Search Bar and See More Results directly within the Libraries. You will only be able to add a total of...
Two Scripts: START then END Application
I'm running low on resources and am not wanting to upgrade, so it looks like a script to the rescue! Basically I work with Oracle 11g on my computer. Here are the 2 scripts that I'm looking to do. Please help. Thanks. Script 1: Start Oracle 11g START Service A START Service B START...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 09:13.
Twitter Facebook Google+