Alias for any program

by Feb 19, 2012

I want to create alias for some programs. It is fulfilled successfully:

Set-Alias edit "C:Program Files (x86)Notepad++notepad++.exe"

Now the command 'edit' was run . I am doing the export alias 'notepad++.exe' in it PowerShell session. I want export my aliaces:

Export-Alias -Path "$HomeDocumentsMyAliases.txt"

It happens successfully.

Now I restart PowerShell, and do import my settings:

Import-Alias -Path "C:Program Files (x86)Notepad++notepad++.exe" -Force

But I get error message:

PS C:Usersuser> Import-Alias -Path "C:Program Files (x86)Notepad++notepad++.exe" -Force

Import-Alias : Cannot import an alias because line number 1 in the file 'C:Program Files (x86)Notepad++notepad++.exe

' is not a properly formatted CSV line for aliases. Change the line so that it contains four values separated by commas

. If the value contains a comma, then the value must be quoted.

At line:1 char:13

+ Import-Alias <<<<  -Path "C:Program Files (x86)Notepad++notepad++.exe" -Force

    + CategoryInfo          : ReadError: (C:Program File…+notepad++.exe:String) [Import-Alias], FormatException

    + FullyQualifiedErrorId : ImportAliasFileFormatError,Microsoft.PowerShell.Commands.ImportAliasCommand

PS C:Usersuser>

In exported file it row such:

"edit","C:Program Files (x86)Notepad++notepad++.exe","","None"

I tried to add inverted commas, but it hasn't helped.

Variant 1:

"edit","'C:Program Files (x86)Notepad++notepad++.exe'","","None"

Variant 2:

"edit",'"C:Program Files (x86)Notepad++notepad++.exe"',"","None"