C ShellexeCuteex不会通过未从该EXE产生输出来执行参数
C++ ShellExecuteEx does not execute exe with parameter by not generating output from that exe
在过去的几天或几周中。在Visual Studio C 中,我很难使用ShellExecuteEx()
试图在EXE内运行带有一个参数的EXE。发生的方式是我在Visual Studio(甚至在外面(运行调试程序。该程序将启动另一个程序,并且可以成功运行,但是它不会生成.txt文件输出。我不确定是否正确使用了该参数。这是我要实现的步骤:
- start navenest.exe (将打开ScreenCapture.exe的EXE(
- cmd屏幕-MAINTAREST.EXE启动并准备使用ShellexeCuteex启动ScreenCapture.exe
- uac弹出,作为管理员运行
- 新的CMD屏幕-ScreenCapture.exe从参数和目录开始
- screencapture.exe完成命令并关闭
- capturetext.txt由screencapture.exe生成的exe与screencapture.exe。
问题是我在目录中没有获得capturetext.txt或任何证明参数在此程序中工作的证据。
现在,如果我在不使用test.exe的情况下运行screenCapture.exe,则可以使用test.exe,它可以工作并生成.txt文件。
这是代码:
#include "stdafx.h"
#include <isostream>
#include <fstream>
#include <string>
#include <Windows.h>
int main()
{
auto str = _T("C:\UsersEngrskyPicturesScreenshot.png ScreenCapture -l eng")
SHELLEXECUTEINFO shExInfo = {0};
shExInfo.cbSize = sizeof(shExInfo);
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shExInfo.hwnd = 0;
shExInfo.lpVerb = _T("runas");
shExInfo.lpFile = _T("C:/Program File (x86)/Test/ScreenCapture.exe");
shExInfo.lpParameters = str;
shExInfo.lpDirectory = 0;
shExInfo.nShow = SW_SHOW;
shExInfo.hInstApp = 0;
}
示例:使用Just Command提示符,ScreenCapture.exe与参数完美搭配。我这样输入了:
Adminstrator:命令提示
C:Program File (x86)Test> ScreenCapture "C:\UsersEngrskyPicturesScreenshot.png ScreenCapture -l eng"
然后,它将成功运行并编写一个名为ScreenCapture.txt
的输出文件但是,当我尝试使用我制作的exe(此文件(进行运行时。我无法生成输出。
来自ShellExecuteEx
函数的MSDN文档,您首先需要初始化com。该示例使用:
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
相关文章:
- VI工作室代码错误无法打开输出文件主.exe
- 是否可以在C++中基于程序集输出(.dll或.exe)定义变量
- 无法在代码块 IDE 中打开输出文件.exe
- CMD:程序.exe 1< "A:/input.txt"产生无输出
- 在 Windows 命令行中运行.exe在使用 2 种相同方式执行时会产生不同的输出
- C ShellexeCuteex不会通过未从该EXE产生输出来执行参数
- 从 Java 运行C++ .exe程序没有输出,也没有接收输入
- 如何将.EXE从C 项目复制到C#项目的输出目录
- 从 exe 获取输出C++并在 Python 中实时处理它
- 无法打开输出文件___.exe:权限被拒绝
- Delphi 2007 EXE和C++DLL:调试输出:027D4FF8处的堆块在027D5009处修改,超过了请求的9
- 无法读取在cmd.exe管道下启动的进程的输出
- 当我尝试运行此代码输出时"merge.exe has stopped working"?
- 获得程序输出(无错误),但程序.exe在使用 graphics.h 时不起作用
- 将PowerShell.exe的输入和输出重定向到C 中的管道
- 从.exe输出到 cmd
- 如何将opencv和其他dll文件链接到visual studio 2013的输出exe
- CMD.EXE中的控制台输出,通过C 进行powershell.exe
- C++ - 将 ASCII 输出到 cmd.exe
- 从WinPE检测BIOS:遗留或UEFI,使用vbs //将结果从.exe输出到.txt