在C ++中运行Powershell脚本时如何隐藏按任意键继续

山姆

下面是我运行Powershell脚本的C ++代码。脚本运行正常,但是脚本完成后要求在命令提示符下按任意键。

C ++

    void main()
    {
        string strPath = "D:\Share\Mail.ps1";      
        system("powershell -ExecutionPolicy Bypass -F D:\\Share\\Mail.ps1"); 
        executeFile();              

    }

电源外壳:

    $SmtpServer = 'smtp.server.net'  
    $SmtpPort = '2525'
    $SmtpUser = 'test'  
    $smtpPassword = '**********'  
    $MailtTo = '[email protected]'
    $MailFrom = '[email protected]'  
    $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $SmtpUser,                                 
                   $($smtpPassword | ConvertTo-SecureString -AsPlainText -Force)
    $MailSubject = 'Alert : Breach Notification'
    $Body = 'Test'
    $MailCount=0
    $file = 'Test_10242019_5.20.txt'

    Send-MailMessage -To $MailtTo -from $MailFrom -Subject $MailSubject -Body $Body -Attachment 
             $file -SmtpServer $SmtpServer -Port $SmtpPort  -UseSsl -Credential $Credentials

命令提示符给出按任意键继续。

我如何隐藏此cmd。

lets

#include <Windows.h>在您的开头添加main.cpp

Main函数的末尾添加:

HWND wnd = GetConsoleWindow(); ShowWindow(wnd, 0);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

C#表格按任意键继续

按任意键继续在nodejs中

C#-批处理文件输出直到我按某个键后才显示“按任意键继续...”

C ++:如何在按任意键时使无限循环停止?

按任意键继续

Supress PowerShell提示“按任意键继续...”

我该如何使“按任意键继续”

按任意键从另一个脚本继续

按任意键暂停外壳脚本,再按一次继续

从Visual Studio运行控制台应用程序时避免“按任意键继续”

循环时继续迭代/重复,直到按Enter(或任意键)为止

(启动时出现WSL错误)按任意键继续

(启动时出现Ubuntu20.04 WSL错误)按任意键继续

错误:无效的环境阻止。按任意键继续

怎么修 ''。' 不是内部或外部命令,也不是可运行的程序或批处理文件。按任意键继续 。. .' geany 中的错误?

在Shell脚本中按Control + C时如何取消进程?

从C#运行Powershell脚本时出错

按任意键,除了

每当按下任意键时,如何告诉bash top停止回显文本?

当用户按下特定键时如何运行代码c#

对“任意键继续”的编程响应

在Python中实现“按任意键停止刷新”循环

如何在Powershell中隐藏“ PS C:\>”?

在C ++中按ENTER后如何继续执行该程序?

在“不调试开始”模式下显示“按任意键继续...”消息

在外部exe程序上跳过“按任意键继续”

从C#在PowerShell 6中运行PowerShell脚本

使用 Powershell 类在 c# 中运行 Powershell 脚本

在WPF C#中按下TAB键时如何触发事件?