简体   繁体   中英

Run CMD Command through PowerShell

I am trying to run a command in CMD, but would like to run in through PowerShell.

Invoke-Item opens CMD, but I don't how to pass in program.exe argument > file.txt

To run cmd.exe from PowerShell, you don't need to use invoke-item eg:

cmd /c c:\windows\system32\ipconfig > file.txt

However, why not just run?

ipconfig > file.txt

try passing the command in directly with the full path qualifier of program.exe like:

$test= "c:\windows\system32\program.exe argument > file.txt"  
Invoke-Expression $test 

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