Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell with CMD/c to run external command with Parameters

$
0
0

Greeting,

I have an old command line application call Commandline.exe. it run with a parameter to check then show the result. but it need extra "Enter" to confirm

like:

      commandline.exe -s 4567890

1. So I preparing the an answer file which is on an "Enter" (crlf) inside it. called c:\apps\answer.txt.

    use command line in command prompt: (pipe to feed commandline.exe that "Enter"

          type c:\apps\answer.txt | c:\apps\commandline.exe -s 4567890

    it works

2. So in powershell I assembly them together like below,

      cmd.exe /c type c:\apps\answer.txt | c:\apps\commandline.exe -s 4567890

It works in powershell command line as well. but with other code together it does not any more.

$cmd="type c:\apps\answer.txt | c:\apps\commandline.exe -s 4567890"

3. The idea is parameter 45567890 is created by other powershell code , and I do not want to be clear text on the command line.

Thanks and Best Regards,

userausera


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>