# Creating a program alias

**URL:** <https://forums.powershell.org/t/creating-a-program-alias/19335>\
**Category:** PowerShell Help\
**Created:** [May 17, 2022, 6:56pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335 "2022-05-17T18:56:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![rootsmusic](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rootsmusic/32/2377_2.png) [@rootsmusic](https://forums.powershell.org/u/rootsmusic)\
**Post date:** [May 17, 2022, 6:56pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/1 "2022-05-17T18:56:20Z")

</div>

My Windows 10 Pro has Anaconda Powershell Prompt, and its $PSVersionTable is:

> Name Value
> 
> * * *
> 
> PSVersion 5.1.19041.1682  
> PSEdition Desktop  
> PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}  
> BuildVersion 10.0.19041.1682  
> CLRVersion 4.0.30319.42000  
> WSManStackVersion 3.0  
> PSRemotingProtocolVersion 2.3  
> SerializationVersion 1.1.0.1

I have to “run as Administrator” in order to run commands in Anaconda Powershell Prompt. I’m unfamiliar with its commands though, except to activate a conda environment. After I’ve activated a conda environment (that’s customized for Microsoft Power BI Desktop), I can start the program at C:\Program Files\WindowsApps\Microsoft.MicrosoftPowerBIDesktop\_2.105.664.0\_x64\_\_8wekyb3d8bbwe\bin\PBIDesktop.exe .

Since that path is so long, I want to create a program alias. I followed the [instructions to add a new key](https://www.itprotoday.com/windows-78/how-can-i-create-program-alias) in Registry Editor. But why do I get the error:

> start : This command cannot be run due to the error: The system cannot find the file specified.  
> At line:1 char:1  
> start PBIDesktop
> 
> ```auto
> + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
> + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
> 
> ```

P.S. if I click on the shortcut icon for Power BI after activating the conda environment, Power BI will still show a Python script error. Apparently, it still needs to be started from the conda environment.

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [May 17, 2022, 8:23pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/2 "2022-05-17T20:23:25Z")

</div>

Hi, welcome to the forum 👋

I know nothing about the prompt you’re using, but if it uses a PowerShell profile, get the path with:

```auto
$Profile

```

You can add the alias in there.

```auto
New-Alias -Name np -Value 'C:\Windows\System32\notepad.exe'

```

---

<div class="post-metadata">

**Author:** ![rootsmusic](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rootsmusic/32/2377_2.png) [@rootsmusic](https://forums.powershell.org/u/rootsmusic)\
**Post date:** [May 17, 2022, 8:42pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/3 "2022-05-17T20:42:13Z")

</div>

$Profile outputs: C:\Users\admin\Documents\WindowsPowerShell\Microsoft.PowerShell\_profile.ps1

But I don’t see any files in that subfolder.

> ```
> Directory: C:\Users\admin\Documents\WindowsPowerShell
> 
> ```
> 
> Mode LastWriteTime Length Name
> 
> * * *
> 
> d----- 3/25/2022 8:43 AM Scripts

Am I supposed to open Microsoft.PowerShell\_profile.ps1 in a text editor to add the New-Alias? Thanks.

P.S. I assume that Ananconda Powershell Prompt loads Windows Powershell.

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [May 17, 2022, 9:46pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/4 "2022-05-17T21:46:17Z")

</div>

> [@rootsmusic](#):
>
> Am I supposed to open Microsoft.PowerShell\_profile.ps1 in a text editor to add the New-Alias

Yes, or do it from the prompt, whatever you prefer:

```auto
Add-Content -Path $profile -Value 'Set-Alias np C:\Windows\System32\notepad.exe'

```

You will need to close and reopen your console for it to take effect.

---

<div class="post-metadata">

**Author:** ![rootsmusic](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rootsmusic/32/2377_2.png) [@rootsmusic](https://forums.powershell.org/u/rootsmusic)\
**Post date:** [May 17, 2022, 10:24pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/5 "2022-05-17T22:24:26Z")

</div>

As explained in my reply, I couldn’t find Microsoft.PowerShell\_profile.ps1 to be able to edit it. Since I’m unfamiliar with the commands in your code, I copy-and-pasted both lines of code into Windows Powershell. Neither line started Notepad, and neither returned an output. For the long path given in my reply, the alias that I want to create is: PBIDesktop. Should the line(s) be modified? Thanks!

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [May 18, 2022, 7:41am UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/6 "2022-05-18T07:41:52Z")

</div>

You either create the file in Notepad, or use the command I provided.

The command:

```auto
Add-Content -Path $profile -Value 'Set-Alias np C:\Windows\System32\notepad.exe'

```

Will create the file if it doesn’t exist, and append the line to it if it does.

It doesn’t open Notepad, it’s an example of how to create an alias ‘np’ to open Notepad from the prompt.

You will need to modify it to create your own alias.

---

<div class="post-metadata">

**Author:** ![rootsmusic](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rootsmusic/32/2377_2.png) [@rootsmusic](https://forums.powershell.org/u/rootsmusic)\
**Post date:** [May 18, 2022, 2:21pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/7 "2022-05-18T14:21:13Z")

</div>

Powershell re-opens with the error:

```auto
Set-Alias : A positional parameter cannot be found that accepts argument 'Files
\WindowsApps\Microsoft.MicrosoftPowerBIDesktop_2.105.664.0_x64__8wekyb3d8bbwe\b
in\PBIDesktop.exe'.
At
C:\Users\admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:1
char:1
Set-Alias PBIDesktop C:\Program Files\WindowsApps\Microsoft.Microsoft ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidArgument: (:) [Set-Alias], ParameterBindingException
FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetAliasCommand

```

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [May 18, 2022, 2:31pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/8 "2022-05-18T14:31:13Z")

</div>

Try putting the path in quotes. You have a space in the path.

---

<div class="post-metadata">

**Author:** ![rootsmusic](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rootsmusic/32/2377_2.png) [@rootsmusic](https://forums.powershell.org/u/rootsmusic)\
**Post date:** [May 18, 2022, 2:51pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/9 "2022-05-18T14:51:18Z")

</div>

Ok, my alias has linked to the program. But when I type in the alias at the Powershell prompt, the program tries to open itself as a document. The program shows an error before immediately closing:

> Unable to open document  
> ‘C:\Program Files\WindowsApps\Microsoft.MicrosoftPowerBIDesktop\_2.105.664.0\_x64\_\_8wekyb3d8bbwe\bin\PBIDesktop.exe’ does not have a valid extension.

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [May 18, 2022, 3:08pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/10 "2022-05-18T15:08:22Z")

</div>

Please post the content of your profile file.

---

<div class="post-metadata">

**Author:** ![rootsmusic](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rootsmusic/32/2377_2.png) [@rootsmusic](https://forums.powershell.org/u/rootsmusic)\
**Post date:** [May 18, 2022, 3:35pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/11 "2022-05-18T15:35:54Z")

</div>

Microsoft.PowerShell\_profile.ps1 has the content:  
`Set-Alias PowerBI 'C:\Program Files\WindowsApps\Microsoft.MicrosoftPowerBIDesktop_2.105.664.0_x64__8wekyb3d8bbwe\bin\PBIDesktop.exe'`

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [May 18, 2022, 8:24pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/12 "2022-05-18T20:24:29Z")

</div>

Looks OK. I don’t have that application so I can’t test it.

Suggest setting an alias to a different app to confirm that works, and if it does, perhaps seeking further advice in a PowerBI specific forum.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/creating-a-program-alias/19335/13 "2024-05-16T20:17:58Z")

</div>

Closed on May 16, 2024, 8:17pm UTC


