下面是我运行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。
#include <Windows.h>
在您的开头添加main.cpp
在Main
函数的末尾添加:
HWND wnd = GetConsoleWindow(); ShowWindow(wnd, 0);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句