【发布时间】:2014-08-02 13:22:18
【问题描述】:
我在 powershell scrpit 的帮助下实现了网络统计程序。该程序运行成功,并给了我完美的输出。下面是我的程序。
int main(int argc, char *argv[])
{
string strPath = "C:\\Get-NetworkStatistics.ps1";
char str[50] = "C:\\Get-NetworkStatistics.ps1";
char command[500];
//access function:
//The function returns 0 if the file has the given mode.
//The function returns –1 if the named file does not exist or does not have the given mode
if(access(strPath.c_str(),0) == 0)
{
_snprintf(command, sizeof(command), "Start Powershell.exe -noexit Set -executionpolicy;.'%s';Get-NetworkStatistics",str);
system(command);
}
else
{
system("cls");
cout << "File is not exist";
system("pause");
}
return 0;
}
! here is the output of above program
如您所见,输出位于 powershell 窗口中。我想获取 powershell 输出的所有这些数据并希望在控制台中显示它。怎么可能?
请帮帮我..
【问题讨论】:
标签: c++ visual-c++ powershell cmd console