createprocess

CreateProcessWithLogonW() problems - Need to launch sub-processes with the same user

佐手、 提交于 2019-12-06 15:51:26
I have a Windows executable that is launched from within a service by calling CreateProcessWithLogonW() with a set of specfied user details. This works fine and the process starts as expected. However, when this process tries to launch other processes itself, currently just using CreateProcess() these start then die straight away - they are executables that require desktop access. After reading up on Microsoft's article on CreateProcess() - http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx I think can see why this is happening and it makes sense to an extent. CreateProcess() knows

How can I create a process in a portable manner?

房东的猫 提交于 2019-12-06 11:34:03
I'm trying to write a program which needs to create some other processes. I'm used to the Windows API but now I need my program to be able to run in a Linux platform too. Is it possible to do it in a portable manner? Do I have to use the preprocessor for that purpose? EDIT: I need to wait for it to finish before continuing to do things. In my opinion the system function should always be avoided: it's unreliable, since you don't know what shell will handle your command and it doesn't have means to return you an unambiguous error code. Moreover, on platforms like Windows where processes are

How to use or expand environment variables in a command instantiated by CreateProcess?

帅比萌擦擦* 提交于 2019-12-06 10:20:13
问题 The following code utilizes CreateProcess to run commands with environmental variables. Here, it tries to run notepad %APPDATA%\test.txt . If I run notepad %APPDATA%\test.txt directly within Windows' CMD , %APPDATA% will be expanded. However, the environmental variable can not be expanded when executed by CreateProcess . Could you help to comment on the reason and the workaround? Any comment will be appreciated! program TestConsole2; {$APPTYPE CONSOLE} uses Windows, SysUtils; var I: Integer;

Using CreateProcess to invoke an exe file?

泪湿孤枕 提交于 2019-12-06 00:22:45
Been trying to invoke the Truecrypt exe from my Visual Studio C++ application, but CreateProcess just isn't working. GetLastError() shows 127 . The objective is to invoke the exe without showing the command window . Please help. I've tried searching and also reading the CreateProcess parameter explanation . #include <stdio.h> #include <stdlib.h> #include <iostream> #include<Windows.h> int main( void ) { HANDLE StdInHandles[2]; HANDLE StdOutHandles[2]; HANDLE StdErrHandles[2]; CreatePipe(&StdInHandles[0], &StdInHandles[1], NULL, 4096); CreatePipe(&StdOutHandles[0], &StdOutHandles[1], NULL, 4096

Call Python from Java

≯℡__Kan透↙ 提交于 2019-12-05 21:56:16
I want to call a python script from Java. My python version is 2.5 and Java is 6. My current code: try{ Process p= Runtime.getRuntime().exec("path/dirs/file.py"); p.waitFor(); } catch (InterruptedException ex){ System.out.println(ex.getMessage());} } The error I receive is: Java.IO.IOException: Cannot run program filename: CreateProcess error = 193, %1 is not a valid Win32 application Try to use PrecessBuilder - try{ String prg = "import sys\nprint int(sys.argv[1])+int(sys.argv[2])\n"; BufferedWriter out = new BufferedWriter(new FileWriter("test1.py")); out.write(prg); out.close(); int number1

“Wrong” app gets pinned to taskbar (Windows 7)

≯℡__Kan透↙ 提交于 2019-12-05 19:57:35
I have an application that gets started via a shortcut. This application than starts a Java GUI application with CreateProcess(). When the Java application gets pinned to the taskbar the javaw.exe gets pinned to the taskbar instead of the "expected" shortcut. Only the native executable which launches Java can be modified - the shortcut has to stay. What has to be done so that the shortcut gets pinned? Thanks, Stefan Use something like winrun4j or create a .bat instead of using a shortcut. There is a Java library providing the new Windows 7 features for Java. It's called J7Goodies by Strix Code

Why is %1 rarely substituted in “%1 is not a valid Win32 application.”

回眸只為那壹抹淺笑 提交于 2019-12-05 13:16:41
I'm sure most Windows developers are familiar with this error message, usually when trying to mix 32- and 64-bit executables. In particular Python and Java can both get it. %1 is not a valid Win32 application. It's clear that %1 represents the first argument to the failing command - i.e. the executable that is trying to be loaded - but why does it not get filled in with the actual path? Is it something that the caller is doing wrong, or is it a basic failing of some Windows subsystem that cannot be fixed for compatibility reasons? Mark Ransom The error message comes from Windows itself, you

AssignProcessToJobObject fails with “Access Denied” error when running under the debugger

ぃ、小莉子 提交于 2019-12-05 12:44:30
问题 You do AssignProcessToJobObject and it fails with "access denied" but only when you are running in the debugger. Why is this? 回答1: This one puzzled me for for about 30 minutes. First off, you probably need a UAC manifest embedded in your app (as suggested here). Something like this: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <!-- Identify the application security requirements. --> <trustInfo xmlns="urn

CreateProcess does not create additional console windows under Windows 7?

女生的网名这么多〃 提交于 2019-12-05 02:27:16
问题 I am trying to run a process using CreateProcess(...) and run it independently in a seperate console window. I can achieve this using the system("...") function, but I prefer CreateProcess since it gives me the possibility to specify environment and working directory, get a handle to the process, as well as piping stdin/out when I need to. All I find on the internet is the inverse problem, which is people having additional console windows and wanting to get rid of them! It appears it was the

Using a handle to collect output from CreateProcess()

梦想与她 提交于 2019-12-04 18:03:59
问题 I am using CreateProcess() to run an external console application in Windows from my GUI application. I would like to somehow gather the output to know whether there were errors. Now I know I have to do something with hStdOutput, but I fail to understand what. I am new to c++ and an inexperienced programmer and I actually don't know what to do with a handle or how to light a pipe. How do I get the output to some kind of variable (or file)? This is what I have a the moment: void email::run