Windows Vista Forums

Exit = last of the "built-in commands"?

  1. #1


    Lucvdv Guest

    Exit = last of the "built-in commands"?

    Just curious: are there any other built-in commands (in the old cmd
    terminology) left over besides "exit"?

    Exit does what I expected it to do, quit didn't do anything, and after
    finding that out I just noticed this:

    PS C:\> set-alias quit exit
    PS C:\> quit
    Cannot resolve alias 'quit' because it refers to term 'exit', which is not
    recognized as a cmdlet, function, operable program, or script file. Verify
    the term and try again.
    At line:1 char:4
    + quit <<<<

      My System SpecsSystem Spec

  2. #2


    dreeschkind Guest

    RE: Exit = last of the "built-in commands"?

    "Lucvdv" wrote:

    > Just curious: are there any other built-in commands (in the old cmd
    > terminology) left over besides "exit"?


    Well, PowerShell has its own scripting language (IMHO cmd.exe does not have
    anything that comes close to being a language) so you could just compare
    "exit" with other common language keywords like "for" "while" "switch"
    "break" etc.

    > Exit does what I expected it to do, quit didn't do anything, and after
    > finding that out I just noticed this:
    >
    > PS C:\> set-alias quit exit
    > PS C:\> quit
    > Cannot resolve alias 'quit' because it refers to term 'exit', which is not
    > recognized as a cmdlet, function, operable program, or script file. Verify
    > the term and try again.
    > At line:1 char:4
    > + quit <<<<


    Thill will work:
    PS> function exit {exit}
    PS> set-alias quit exit
    PS> quit

    or even shorter:
    function quit {exit}

    Btw.:
    I suggested that "exit" should be a customizable function like TabExpansion
    or Prompt. This would enable for example saving or cleaning up various data
    automatically (e.g. exporting history) when closing PowerShell without the
    need to remember to call a special function or cmdlet with another name.
    You can vote for this on the Connect site if you like this idea:

    https://connect.microsoft.com/feedba...8962&SiteID=99

    --
    greetings
    dreeschkind

      My System SpecsSystem Spec

  3. #3


    Alex K. Angelopoulos [MVP] Guest

    Re: Exit = last of the "built-in commands"?

    "Lucvdv" <replace_name@null.net> wrote in message
    news:n3k6l21p7sfs9bnk956rp2uqhkl4g8vrar@4ax.com...
    > Just curious: are there any other built-in commands (in the old cmd
    > terminology) left over besides "exit"?


    Technically, it's not a command; it's an internal keyword used for control
    flow, akin to break/continue/return/if and so on.

    > Exit does what I expected it to do, quit didn't do anything, and after
    > finding that out I just noticed this:
    >
    > PS C:\> set-alias quit exit
    > PS C:\> quit
    > Cannot resolve alias 'quit' because it refers to term 'exit', which is not
    > recognized as a cmdlet, function, operable program, or script file. Verify
    > the term and try again.
    > At line:1 char:4
    > + quit <<<<


    You've stumbled across one of the important points about how PowerShell
    interprets code. Here's another way to explain it.

    PowerShell starts out in "expression" mode, attempting to match tokens to
    things it understands internally: specific keywords, variables, or literal
    values. If it doesn't find a match, it then goes to statement mode and tries
    to treat the token as a command.

    Since 'quit' is not recognized internally PS now tries to treat it as a
    command, and sure enough, it's an alias for "exit". However, aliasing ONLY
    works for commands! It looks for an alias,function,filter,cmdlet, or
    external script or Windows native command named "exit" and doesn't find one.



      My System SpecsSystem Spec


Exit = last of the "built-in commands"?
Similar Threads
Thread Forum
Re: Why does exiting "server management" exit my Terminal Server session? SBS Server
How to restore "RUN" and "Help and Support" commands General Discussion
Cant turn off "built in protection"... Vista security
Acer Aspire 3023 Problem enabling "radio" for built in broadcom wi Vista hardware & devices
Acer Aspire 3023 Problem enabling "radio" for built in broadcom wi Vista hardware & devices