How does the PowerShell command contain spaces to run? _powershell

Source: Internet
Author: User
Tags rar

In PowerShell, you can run the command directly. An executable program that includes the end of the. com end of. exe, including the end of. bat, the. cmd end of the batch program, and the. PS1 end of the. You can run a program by using the following methods:

< program file name >.< suffix > [parameter list]

Note, however, that the < program file name > In fact refers to a path that can be relative or absolute. When we use the absolute path, we will encounter the path with a space, like the above to execute it, it will be an error.

So, how do you run a command with a space?

The answer is in quotes! Double quotes, single quotes are all available. For example, C:\Program Files\winrar\rar.exe, this is a Winrar with a command-line tool, can be used to compress or extract. rar files, very useful. If we're going to call it in PowerShell, we can use the following methods:

Copy Code code as follows:

& ' C:\Program files\winrar\rar.exe ' < parameter list >

Small series to analyze, first of all, the command with a space in quotation marks. Put the list of parameters outside the program. Then use a program call (&) to make the call. It's so simple!

Well, you can also use this way to invoke a space-delimited command that you want to run.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.