从函数WriteConsoleInput中抑制控制台键输入 [英] Suppress console key input from function WriteConsoleInput

查看:357
本文介绍了从函数WriteConsoleInput中抑制控制台键输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


您好


我正在开发一个在powershell控制台上执行命令的MFC应用程序。

exe本身是从powershell控制台调用的。

exe附加到父控制台并在控制台上写命令。

随后该命令被执行powershell控制台。

这个exe使用函数WriteConsoleInput写入控制台



示例运行

== ============

PowerCLI C:\ TVME \TestSignedExe> .\tdc.deploy.exe .\Properties\common.IT.properties.json .\Properties\\\
ode.IT.properties.json

PowerCLI C:\ TVME \ TestSignedExe> iex([System.Text.Encoding] :: UNICODE.GetString((gp -path([Environment] :: GetEnvironmentVaria

检查Power-Shell版本.....



在上面的代码片段中,tdc.deploy.exe是从powershell控制台调用的exe,而
iex ....是在控制台上执行的命令。



我试图用不同的方法来抑制命令iex ..在控制台上显示。

我试图执行命令没有在控制台上显示。



如果有办法,请告诉我。

我是否需要问这个问题向Powershell团队提出问题。

如果有任何其他方法可以通过exe在控制台上执行命令,请告诉我。



谢谢你
Srikanth





$




$


$


$

解决方案

嗨Doosa Srik我希望在这里发布。


>>我正在尝试以不同的方式来抑制命令iex ..来自在控制台上显示。

我试图执行命令而不在控制台上显示它。


请提供有关您的要求的更多信息。你如何运行命令?在PowerShell中还是与您的应用程序一起使用?


WriteConsoleInput函数用于将数据直接写入控制台输入缓冲区。如果我没有误解你的问题,我建议你使用

system
方法直接运行命令而不在控制台中显示它。


如果你想用PowerShell静默运行命令, 你可以在下面这个论坛发帖。


https://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverpowershell


希望这可以为您提供帮助。


最好的问候,


Baron Bi



Hi

I am working on an MFC application that executes a command on powershell console.
The exe itself is invoked from powershell console.
The exe attaches to the parent console and writes a command on the console.
subsequently that command gets executed on the powershell console.
This exe uses function WriteConsoleInput to write to the console

Example run
==============
PowerCLI C:\TVME\TestSignedExe> .\tdc.deploy.exe .\Properties\common.IT.properties.json .\Properties\node.IT.properties.json
PowerCLI C:\TVME\TestSignedExe> iex ([System.Text.Encoding]::UNICODE.GetString((gp -path ([Environment]::GetEnvironmentVaria
Checking Power-Shell Version.....

In the above snippet tdc.deploy.exe is the exe invoked from powershell console and
iex.... is the command that is executed on the console.

I am trying at different ways to suppress the command iex.. from getting displayed on the console.
I trying to execute the command without displaying it on the console.

Please let me know if there are any ways to do it.
Do I need to ask this question to the Powershell Team.
Also please let me know if there are any other methods to execute a command on the console from an exe.

Thanks
Srikanth










解决方案

Hi Doosa Srikanth,

thanks for posting here.

>>I am trying at different ways to suppress the command iex.. from getting displayed on the console.
I trying to execute the command without displaying it on the console.

Please provide more information about your requirement. How do you run the command? In PowerShell or with your application?

The WriteConsoleInput function is used to write data directly to the console input buffer. If I don't misunderstand your issue, I suggest you use system method to run the command directly without showing it in your console.

If you want to run the command silently with PowerShell,  you could post on this forum below.

https://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverpowershell

Hope this could be help of you.

Best Regards,

Baron Bi


这篇关于从函数WriteConsoleInput中抑制控制台键输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆