createprocess

How do I launch a process and obtain its output?

馋奶兔 提交于 2019-11-28 02:16:28
In the C language using the Windows API, how can I get the output of a process when I have its process information? I have code like this: STARTUPINFO si1; ZeroMemory(&si1,sizeof(si1)); PROCESS_INFORMATION pi1; ZeroMemory(&pi1,sizeof(pi1)); BOOL bRes1=CreateProcess(_T("C:\\User\\asd.exe"),cmd_line1,NULL,NULL,FALSE,CREATE_NO_WINDOW,NULL,NULL, &si1,&pi1); and the process asd.exe prints a certain output, I want to get it to my process(the one i used the code above in). This answer is probably a bit longer than you expected, but that's how the Windows API is sometimes. In any case, even though

CreateProcess with new console window, but override some std i/o handles

夙愿已清 提交于 2019-11-27 18:53:09
问题 If you use CreateProcess with the flag CREATE_NEW_CONSOLE, the new process has its standard input, output, and error handles directed to the new console window. If you want to override the I/O streams, you can do so by setting the handles in STARTUPINFO fields hStdOutput, hStdInput, and hStdError and setting the flag STARTF_USESTDHANDLES. But what if you want to override only one of the handles? For example, I might want to redirect stderr to a file while leaving the stdout and stdin

Use CreateProcess to Run a Batch File

一个人想着一个人 提交于 2019-11-27 15:09:53
I am trying to use CreateProcess to start a new environment block and run a batch file in the new environment block. I've read through the msdn example for CreateProcess, and came up with the code shown below. What is happening, it will open the new command prompt, and stop there. It will not run my .bat file for some reason. Using system("CALL path") will call the .bat file. #include <iostream> #define WINDOWS_LEAN_AND_MEAN #include <Windows.h> #include <strsafe.h> #define BUFSIZE 4096 int main() { //system("CALL C:\\HFSS\\setup_vars.bat"); //return 0; LPWCH chNewEnv; LPTSTR

Access Violation in function CreateProcess in Delphi 2009

雨燕双飞 提交于 2019-11-27 14:02:30
问题 In my program I've the following code: //Code if not CreateProcess(nil, NonConstCmd, nil, nil, True, NORMAL_PRIORITY_CLASS or CREATE_NEW_PROCESS_GROUP, nil, PCh, SI, P) then //Code And I keep getting Access violation error. By the way, in Delphi7 the same code works perfectly. I've read MSDN and found that CreateProcess function in Delphi can modify the second argument. Inititally It was const, that's why I create a new variable with the same value. But it takes no effect. The question is:

CreateProcess doesn't pass command line arguments

蓝咒 提交于 2019-11-27 09:11:57
Hello I have the following code but it isn't working as expected, can't figure out what the problem is. Basically, I'm executing a process (a .NET process) and passing it command line arguments, it is executed successfully by CreateProcess() but CreateProcess() isn't passing the command line arguments What am I doing wrong here?? int main(int argc, char* argv[]) { PROCESS_INFORMATION ProcessInfo; //This is what we get as an [out] parameter STARTUPINFO StartupInfo; //This is an [in] parameter ZeroMemory(&StartupInfo, sizeof(StartupInfo)); StartupInfo.cb = sizeof StartupInfo ; //Only compulsory

How to run application which requires admin rights from one that doesn't have them [closed]

廉价感情. 提交于 2019-11-27 06:55:00
I've been stuck on this for a few hours until I've finally managed to do it. There are already links which pointed me the right direction: Is it possible for the executable to ask for Administrator rights? (Windows 7) CreateProcess error=740, The requested operation requires elevation But I've thought that simple overview of the problem could help someone :). Real problem: (from Wikipedia: http://en.wikipedia.org/wiki/User_Account_Control ) An executable that is marked as "requireAdministrator" in its manifest cannot be started from a non-elevated process using CreateProcess(). Instead, ERROR

Making CreateProcess inherit the console of the calling process

三世轮回 提交于 2019-11-27 06:13:51
问题 When I call CreateProcess in Windows, the new process doesn't seem to inherit the console of the calling process. I made a test program that runs "ruby xtest", xtest being a script that writes "hello" to standard output. I ran this test program from Emacs, and get no output. I also tried the following code calling GetStdHandle, but again, no output. Then I tried passing CREATE_NEW_CONSOLE in dwCreationFlags to CreateProcess, which made a whole new window with the Ruby output. Finally, I made

Delphi 虚拟桌面

不想你离开。 提交于 2019-11-27 05:04:51
Delphi创建虚拟桌面实现后台调用外部程序 核心提示:最近在做的一个软件,其中有一部分功能需要调用其它的软件来完成,而那个软件只有可执行文件,根本没有源代码,幸好,我要做的事不难,只需要在我的程序启动后,将那个软件打开,在需要的时候,对其中的一个文本框设置一些文字,再点击一个按钮就可以了。... 最近在做的一个软件,其中有一部分功能需要调用其它的软件来完成,而那个软件只有可执行文件,根本没有源代码,幸好,我要做的事不难,只需要在我的程序启动后,将那个软件打开,在需要的时候,对其中的一个文本框设置一些文字,再点击一个按钮就可以了。 说到这里,相信你也有了对该功能的一些初步设想了,没错,其基本思路就是: 1)调用CreateProcess()打开目标程序。 2)用FindWindow()找到目标程序的窗口Handle。 3)找到文本框的Handle,以及按钮的MessageID,用SendMessage()方法设置文字,并触发事件。 好了,这样确实很简单吧,但是当我实现它后,却发现这样做的结果则是:当我的程序启动并打开目标程序时,它的Splash窗口,以及主窗口都将显示出来,即使当我用FindWindow()找到主窗口Handle后,调用SendMessage(WindowHandle, SW_HIDE)来隐藏该窗口,还是会有一瞬主窗口被显示出来的

Is it possible to execute a .NET dll without an exe to load it?

不问归期 提交于 2019-11-27 02:10:38
问题 I'm curious if there's a way to execute a static .DLL method in a new process without having to create an .EXE for it? AFAIK, this isn't possible with native Win32/64 DLLs. How about .NET DLL assemblies? UPDATE : I forgot to mention I'm primarily interested in doing this programmatically (from C# code, to be specific). Thanks! CONCLUSION : Although no one "dared" to spell it out, the answers all seem to lean towards 'no'. One needs to start a process through one of the conventional ways (EXE,

CreateProcess() fails with an access violation [duplicate]

情到浓时终转凉″ 提交于 2019-11-27 02:08:36
This question already has an answer here: Unhandled Error with CreateProcess [duplicate] 2 answers My aim is to execute an external executable in my program. First, I used system() function, but I don't want the console to be seen to the user. So, I searched a bit, and found CreateProcess() function. However, when I try to pass a parameter to it, I don't know why, it fails. I took this code from MSDN, and changed a bit: #include <windows.h> #include <stdio.h> #include <tchar.h> void _tmain( int argc, TCHAR *argv[] ) { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb