Jacek
Jacek

Reputation: 12053

How to create PS alias for EXE with many path parameters?

Why such alias doesn't work? In my opinion there is problem with duplicated quotation marks.

New-Alias -Name "chrome" -Value ""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="%APPDATA%\Google\Chrome\User Data" --disk-cache-dir="%LocalAppData%\Google\Chrome\User Data""

Upvotes: 1

Views: 252

Answers (1)

Maximilian Burszley
Maximilian Burszley

Reputation: 19644

To add to @boxdog's comment, pointing to the alias documentation, you must point your alias to a function if you want parameters.

Consider adding this to your $profile to accomplish your goal:

function Start-Chrome {
    $argList = @(
        "--user-data-dir=`"$Env:AppData\Google\Chrome\User Data`""
        "--disk-cache-dir=`"$Env:LocalAppData\Google\Chrome\User Data`""
    )
    & "${Env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe" @argList
}
New-Alias -Name chrome -Value Start-Chrome

Upvotes: 4

Related Questions