简体   繁体   中英

How do I change directory and run a file in that directory in powershell?

For example, i want to run cygwin.bat which is located in the c:/cygwin/ directory...

I tried the following but got an error:

cd c:/cygwin ./cygwin.bat

cd c:/cygwin and ./cygwin.bat are two different statements. You can execute them from the interactive console like so:

PS C:\>       cd c:/cygwin 
PS C:\cygwin> ./cygwin.bat

Or, if you really want to do it on the same line, then use a ; between them to indicate separate statements.

cd c:/cygwin ; ./cygwin.bat

best way is the way its always been

c:\cygwin\cygwin.bat

it's all you need to type

Try iex

$command = "cd c:/cywin"
iex $command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM