Sunday 15 January 2012

How to create a cmd/PowerShell alias that can be used with arguments -


I want to be able to type that type without typing

  php: \ Zftool \ zftool.phar Create Project e: \ test   

So I have created a zf.cmd file containing it

  php e: \ zftool \ Zftool.phar% 1% 2% 3   

But when I enter

  create zf project E: \ test   

This only executes the nickname

  php e: \ zftool \ zftool.phar   

How can I fix it? thank you in advanced.

=========================================== =====================================

[edit ]:

Solved my problem, proposed solution, but if you create a function on the runtime, you will lose its definition after shutting down the PowerShell window.

To continue it for every session, you must add that function to your profile:

  1. Open Windows PowerShell.

  2. Enter Notepad $ profile command If it opens an empty anonymous file, you should close it and new item-path You should create a new $ profile with $ profile-type file command.

  3. Paste your function code inside the file that you just created, save it and you're ready to go.

    If an error message such as

    "file can not be loaded because execution of scripts on this system is disabled" >

    It can be determined by entering

    Set-Execution Policy Unrestricted or Set-Execution Policy Unrestricted-Force

    In your case I use .cmd file not < / Strong>. I will create a PowerShell function zf with 3 parameters zf function Appeal-expression CMDLET or & amp; ; .

      zf ($ p1, $ $ PathToPHPExe = "C: \ PHP \ PHP.exe" [string] $ pathToFILE = "E: \ zftool \ zftool.phar" [array] $ argument = $ Path toFILE, $ p1, $ P2, $ P3 & $ PathToPHPExe $ logic}    

No comments:

Post a Comment