<p>Example: You have a shortcut <code>s</code> to <code>SomeProgram</code> in the current directory.</p>

<p>In <code>cmd.exe</code>, you can type <code>s</code> and it will launch the program.</p>

<p>In PowerShell, typing <code>s</code> gives:</p>

<blockquote>
  <p><code>The term 's' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.</code></p>
</blockquote>

<p>If you type <code>s.lnk</code> or <code>SomeProgram</code>, it runs the program just fine.</p>

<p>How can I configure PowerShell to execute shortcuts just like programs?</p>

[{'answer_id': 22934, 'author': 'Steven Murawski', 'author_id': 1233, 'author_profile': 'https://Stackoverflow.com/users/1233', 'pm_score': 2, 'selected': False, 'text': "<p>I don't believe you can.  You might be better off aliasing commonly used commands in a script that you call from your profile script.</p>\n\n<p>Example -</p>\n\n<p>Set-Alias np c:\\windows\\notepad.exe</p>\n\n<p>Then you have your short, easily typeable name available from the command line.</p>\n"}, {'answer_id': 22955, 'author': 'Lee', 'author_id': 1954, 'author_profile': 'https://Stackoverflow.com/users/1954', 'pm_score': 0, 'selected': False, 'text': '<p>You can always use tab completion to type "s[TAB]" and press ENTER and that will execute it.</p>\n'}, {'answer_id': 23004, 'author': 'bruceatk', 'author_id': 791, 'author_profile': 'https://Stackoverflow.com/users/791', 'pm_score': 4, 'selected': True, 'text': "<p>On my Vista system typing S won't launch a lnk file unless I have the environment variable PATHEXT set with .lnk in the list.  When I do. S will work in cmd.exe and I have to do .\\S in powershell.</p>\n"}, {'answer_id': 23687, 'author': 'slipsec', 'author_id': 1635, 'author_profile': 'https://Stackoverflow.com/users/1635', 'pm_score': 2, 'selected': False, 'text': '<p>For one, the shortcut is not "s" it is "s.lnk".  E.g. you are not able to open a text file (say with notepad) by typing "t" when the name is "t.txt" :) <a href="http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection127121120120" rel="nofollow noreferrer">Technet says</a> </p>\n\n<blockquote>\n  <p>The PATHEXT environment variable\n  defines the list of file extensions\n  checked by Windows NT when searching\n  for an executable file. The default value of PATHEXT is .COM;.EXE;.BAT;.CMD</p>\n</blockquote>\n\n<p>You can dot-source as described by others here, or you could also use the invocation character "&amp;".  This means that PS treats your string as something to execute rather than just text.  This might be more important in a script though.</p>\n\n<p>I\'d add that you should pass any parameters OUTSIDE of the quotes (this one bit me before) note that the "-r" is not in the quoted string, only the exe.</p>\n\n<pre><code>&amp; "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_regiis.exe" -r | out-null\n</code></pre>\n'}, {'answer_id': 23694, 'author': 'Emperor XLII', 'author_id': 2495, 'author_profile': 'https://Stackoverflow.com/users/2495', 'pm_score': 3, 'selected': False, 'text': "<p>After adding <code>;.LNK</code> to the end of my <code>PATHEXT</code> environment variable, I can now execute shortcuts even without the preceding <code>./</code> notation. (Thanks bruceatk!)</p>\n\n<p>I was also inspired by Steven's suggestion to create a little script that automatically aliases all the shortcuts in my <code>PATH</code> (even though I plan to stick with the simpler solution ;).</p>\n\n<pre><code>$env:path.Split( ';' ) | \n  Get-ChildItem -filter *.lnk | \n  select @{ Name='Path'; Expression={ $_.FullName } }, \n         @{ Name='Name'; Expression={ [IO.Path]::GetFileNameWithoutExtension( $_.Name ) } } | \n  where { -not (Get-Alias $_.Name -ea 0) } | \n  foreach { Set-Alias $_.Name $_.Path }\n</code></pre>\n"}, {'answer_id': 65801, 'author': 'Mark Schill', 'author_id': 9482, 'author_profile': 'https://Stackoverflow.com/users/9482', 'pm_score': 4, 'selected': False, 'text': '<p>You can also invoke a shortcut by using the "invoke-item" cmdlet. So for example if you wanted to launch "internet explorer.lnk" you can type the following command:</p>\n\n<pre><code>invoke-item \'Internet Explorer.lnk\'\n</code></pre>\n\n<p>Or you could also use the alias</p>\n\n<pre><code>ii \'internet explorer.lnk\'\n</code></pre>\n\n<p>Another cool thing is that you could do "invoke-item t.txt" and it would automatically open whatever the default handler for *.txt files were, such as notepad.</p>\n\n<p><strong>Note</strong> If you want to execute an application, app.exe, in the current directory you have to actually specify the path, relative or absolute, to execute. ".\\app.exe" is what you would need to type to execute the application.</p>\n'}]
['https://Stackoverflow.com/questions/22524', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2495/']