If you ever have a situation where you cannot use the built-in Process class to launch a process (like if you need to launch the process with a specific access token for example) but you need to be able to redirect the input and output (StdIn and StdOut) of the process to your own program then this should help you out. This only really applies if you are wanting to launch and interact with console applications because GUI applications dont tend to ever look at StdIn or StdOut.
It is not very straight forward and took me ages to get it working so I would certainly advise people to try and use the built in Process class and its redirection abilities wherever possible rather than using this method... but as mentioned above, unfortunately there are some scenarios where this is not possible.
Ive attached the project files for a demo application I've written that lets you launch a process, send text input to it, and read its output in a background thread. I have added loads of comments to it but feel free to ask if you have any questions about how it works.
See end of post for attached project files, but here's an example of what it does:
So as you can see in the example above, I've launched command prompt (hidden) and sent the command "dir" to it (which makes it list all files and folders in the current folder) then sent the command "exit" which makes the command prompt terminate itself, and the program realises and shows an appropriate message.
There are a few quirks, which are as follows: --- On Windows XP some characters in the output do not get displayed correctly - no idea why this is, as I had the same issue on Windows 7 but then I changed the encoding of the text to the encoding that command prompt uses (cp850) rather than ASCII and that sorted it out on Windows 7 but made no difference on XP. Its only some special characters so most people probably wont ever notice this. --- Telnet does not want to work at all, even though every other program I've tried does. --- On Windows XP the output for some commands doesnt have line breaks where it should - ipconfig is the main one I've had issues with. Its still usable, just a bit harder to read because everything is on one line (wrapped). Again this is not an issue on Windows 7.
This code uses the following Windows APIs: CreatePipe ReadFile (for reading the pipe, not a file ) WriteFile (same as above) CloseHandle DuplicateHandle CreateProcess PeekNamedPipe WaitForMultipleObjects
which have of course all been added to my Windows API library that I'm writing see here for more details - http://www.vbforums.com/showthread.php?p=3813700
Project files for redirection demo attached below.
Last edited by chris128; Jun 12th, 2010 at 05:01 PM.
Re: Redirect Process Input/Output with Windows API
When you want to use an access token (http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx) to launch the process as a specific user without having to provide the user's username and password (its not as unsecure as it sounds lol)
Re: Redirect Process Input/Output with Windows API
Cool almost a year ago exactly since I posed this thread lol I've been doing some work recently with launching processes in the user's session from a service on Windows 7 (as services run in their own session in Vista/Win7 and therefore any programs they launch will not be seen by the user). You may well already have a feature like that working (or might not be interested in the user seeing the new process) but if it helps I've put some of the code on my blog here: http://cjwdev.wordpress.com/2011/06/...-on-windows-7/
Let me know if it looks like it might be useful to you and I'll send you the source code for an app I wrote recently that uses this, as the code on the blog is just a basic example that doesn't deal with setting up the user's environmental variables for the new process and doesn't close all of the handles that need closing.
Re: Redirect Process Input/Output with Windows API
I've had the remote execution going for about a year now but they were solely interactive processes although the nice thing is that I could pull the security token from the Explorer process and launch the application as the currently logged in user which is one feature that isn't included in most tools. Probably a security risk for corporations to some extent seeing as with that token I could impersonate and decrypt any data I want access to but it's pretty interesting.
I spent the last 2 days figuring out how to incorporate your example into mine. After a ton of research and trial/error it seems that the only possible way to re-direct the standard output/input through a named pipe is to first create a standard pipe and associate the handles the way you have to the process. First you need to create a server pipe on the client side of the application. As the output is being obtained from the process, you can connect to it from the server side and provide the output. I now have this working both ways for the input and output. I'm about half way done compiling a library that I have absolutely no problem with sharing with everyone which will allow you to call a single static function to create a new process remotely. There are 2 events so far which indicate when standard output has been received and when process details have been received by the client end of the named pipe so that you can hook onto those events and output them to a textbox or whatever you want.
I still need to add in the code to launch the application as the SYSTEM account and as the currently logged in user because I decided to completely re-do this tool in C# instead of VB as I found that my level of understanding this API has considerably increased since switching languages.
I will be sure to update you as soon as possible. This is my main focus now because I need to incorporate this function into another large application I’ve developed.
Re: Redirect Process Input/Output with Windows API
thanks for the update, look forward to seeing the finished library. By the way you don't have to grab the access token from explorer, you can just use WTSQueryUserToken and pass in the user's session ID (which you can get from WTSGetActiveConsoleSessionId). I haven't seen your code but all the other examples I've seen online where people get the token from explorer they then have to mess around duplicating the handle and doing various other things, so personally I find this method to be neater but hey if your code is working fine as it is then probably no point changing it.
Re: Redirect Process Input/Output with Windows API
I'm actually going to try out those 2 methods you have mentioned instead because I've been hearing that some virtual Windows environments have several explorer.exe processes running on the same machine which would definately cause a problem. I'd prefer to obtain the access token another way so that this tool can be used in these scenarios as well.
The finished library will contain the remote server executable embeded as a resource. The client will make a copy of the executable on the remote systems Admin$ share, create and start a new service using WMI, start a command pipe server loop to accept process start commands to obtain process information and StdIn commands to redirect to the process itself. The client just has a single loop to send out the required process information and then it creates a new named pipe server to receive StdOut data along with process start and termination return values. So I'm hoping that once this is complete, anyone can just import my library and call a function like
and receive the string data from the custom event arguement class making it easy to update a textbox or whatever and nothing to really customize other than your interface.
Afterwards the server notifies the client to stop processing and the client will stop and remove the service and delete the server executable. I also coded it so that it will accept a maximum of 10 connections to the named pipe server in order to run several processes remotely on the same machine at a time. The server just keeps track of the processes in an array and communicates the index back to the client. When the client sends commands back it states which part of the array contains the process it is working with. When a process exits, it loops through all of the other process arrays and notifies each client that the array has been resized and what the new index is for it's processing. But now that I think of it, I forgot to make the client re-create it's server pipe with the new index number. I haven't had too much time to test everything yet because I did most of this all from scratch in less than a days worth of time. Also having to port from VB to C# can be annoying because of some of the syntax. In your example you have a line when sending commands to the StdIn Pipe that uses something like String & VbCrLf & VbCr. Well I got stuck for probably an hour because of it. LoL. C# it was String + "\r\n\r";
Re: Redirect Process Input/Output with Windows API
haha yeah its always the stupid little things that take a long time :P
As for the multiple explorer.exe processes, that will only happen if multiple people are logged on (which can happen easily on Windows 7 as it now supports fast user switching even on a domain, or on any server running Terminal Services). So you need to think about how you want to handle that situation - if your app is supposed to launch a process interactively so that the logged on user can see it, what should it do if multiple people are logged on? Should it just launch it for the person logged on to the console session (which is usually the person physically sat at the machine using it, but in the case of terminal servers this will often be no one as only admins would ever log on to the console session), or should it launch the process once for every logged on user, or should it just fail because it is impossible to know which session to launch the process in? The method I outlined in that blog post will just launch the process in the console session. I'll post the source code for my app that uses this technique in another post in a sec. I've only tested it on Windows 7 though as all of our machines at work are now Windows 7, so no idea if it will work on XP correctly.
Oh and also I would loose the WMI stuff - a lot of places don't allow WMI through their workstations firewalls plus WMI is generally considered quite slow (and in my experience unreliable). You could just use the CreateService API (its in my Windows API Library if you are interested) as I believe that only requires the same ports to be open in the firewall that would already need to be open for you to get to the ADMIN$ share. Test it out though obviously, as it may also require the Remote Registry service to be running, which it isnt by default in Windows 7 (but you can easily start the service remotely from your code if not). Which brings me on to my next point...
Make sure you test this on XP and Windows 7 if you are going to be offering this to the developer community to use, as there are major differences between the two when talking about services and you will probably find you need to do things slightly differently depending on which OS the code is running on.
Re: Redirect Process Input/Output with Windows API
Here's the code for the app I wrote that is purely designed to launch a specified process in the desktop session of the logged on user (the console session user):
vb.net Code:
Imports Cjwdev.WindowsApi
Module MainModule
Private Sub ShowUsage()
Console.WriteLine("Launches a process in the currently logged on user's desktop session (and" & vbNewLine & "security context) when called from a Windows service running as Local System" & vbNewLine & vbNewLine & _
Console.WriteLine("Failed to get handle to primary token, the last error reported was: " & New ComponentModel.Win32Exception().Message)
Exit Sub
End If
Console.WriteLine("Creating environmental variable block for user...")
Dim CreateEnvironmentResult As Boolean = ApiDefinitions.CreateEnvironmentBlock(EnvironmentBlock, UserTokenHandle, False)
If CreateEnvironmentResult AndAlso Not EnvironmentBlock = IntPtr.Zero Then
Console.WriteLine("Successfully created environmental variable block")
Else
Console.WriteLine("Failed to create environmental variable block for user, the last error reported was: " & New ComponentModel.Win32Exception().Message)
Re: Redirect Process Input/Output with Windows API
Nice, I'm going to try that out once I get around to adding the option to launch as the current user into my tool. Thanks Chris. I can't wait to get this finished! lol. Need more time in a day.
Re: Redirect Process Input/Output with Windows API
Hey Chris,
I really need some help right now. I haven't tried your last posting yet because I'm having an issue with the named pipe.
The client side application opens a server based "Response" pipe for new output from the server and process information.
The server side just has the server based "Command Pipe" to accept new commands.
If I run the server on a remote machine with the same account as the client, the communication back and forth between the 2 server pipes works perfectly. When I start the server on the remote machine as the SYSTEM account and host it as a service, when the server tries to reply back to the client's SERVER pipe, it get's the access denied message because the default security descriptor of the named pipe created on the client side is using defaults which doesn't include a remote machines SYSTEM account.
I managed to create a new security descriptor and pass it to the SECURITY_ATTRIBUTES structure but when I call CreateNamedPipe it fails indicating that I am accessing protected memory.
The orginal API import set the lpSecurityAttributes type as an IntPtr and the creation of the pipe was fine. I changed it to the SECURITY_ATTRIBUTES type instead so I can pass the new security attributes with the custom security descriptor.
Code:
[DllImport("Advapi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = false)]
private static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor([In] string StringSecurityDescriptor, [In] uint StringSDRevision, [Out] out IntPtr SecurityDescriptor, [Out] out int SecurityDescriptorSize);
private const string SECURITYDESCRIPTORSTRING = "O:WDG:WDD:(A;;FA;;;WD)";
/////////////testing
IntPtr securityDescriptorPtr = IntPtr.Zero;
int securityDescriptorSize = 0;
bool Result = ConvertStringSecurityDescriptorToSecurityDescriptor(SECURITYDESCRIPTORSTRING, 1, out securityDescriptorPtr, out securityDescriptorSize);
SECURITY_ATTRIBUTES SA = new SECURITY_ATTRIBUTES();
SA.nLength = Marshal.SizeOf(SA);
SA.bInheritHandle = false;
SA.lpSecurityDescriptor = securityDescriptorPtr;
/////////////////////////
//Create the command pipe handle.
int PipeHandle = CreatePipe("\\\\.\\pipe\\nRPInPipe" + RemoteProcessIndex.ToString(), (uint)BUFFERSIZE, 10, SA);
private static int CreatePipe(string PipeName, uint BUFFERSIZE, uint MaxConnections, SECURITY_ATTRIBUTES SecurityAttributes)
{
uint openMode = (int)PIPE_ACCESS_DUPLEX | (uint)FILE_FLAG_WRITE_THROUGH;
uint pipeMode = PIPE_WAIT | PIPE_TYPE_MESSAGE;
return CreateNamedPipe(PipeName, openMode, pipeMode, MaxConnections, BUFFERSIZE, BUFFERSIZE, 10000, SecurityAttributes).ToInt32();
}
If I change the API import back to an IntPtr type for the securityattributes and pass IntPtr.zero, it will work fine to create the pipe but with the securityattributes that are useless for what I want to do.
Do you know how to either create a new IntPtr to reference the SA structure that's being passed so I can use my original API or do you know why it is failing in the creation of the pipe when I pass the structure to it? Just so you know, the ConvertStringSecurityDescriptorToSecurityDescriptor is working fine and is returning the intptr to the security descriptor that was created.
Please help, lol. I've been trying to figure this out for hours now.
Re: Redirect Process Input/Output with Windows API
I'm not great with C# so sorry if you are already doing this and I just can't see it, but it sounds like you need to pass that argument (the SECURITY_ATTRIBUTES one) in ByRef rather than ByVal. I can explain why if you want but just try it first and see if it fixes the problem
EDIT: Just did some googling to see how you pass arguments ByRef in C# so I can give you an example of what I think you need to do now. Basically just change this line:
Re: Redirect Process Input/Output with Windows API
LoL, sorry about the hi-jacking. I got it to work properly now. Communication is working perfectly between the 2 server pipes.
First it was the structure for the SECURITY_ATTRIBUTES. Had to change it to a class like so.
[StructLayout(LayoutKind.Sequential)]
internal class SECURITY_ATTRIBUTES
{
public int nLength;
public SafeLocalMemHandle lpSecurityDescriptor;
public bool bInheritHandle;
}
I found a million examples of people having issues with this and had to combine info from a lot of them.
the lpSecurityDescriptor was change from an intptr to a custom class type "SafeLocalMemHandle".
Re: Redirect Process Input/Output with Windows API
You didn't need to make the structure a class you could just pass the structure in ByRef, has the same effect. The reason it didnt work as a structure originally is because the API expects a pointer to one of these structures, not the actual structure itself - which is why it works when you define the argument as IntPtr and not when you pass in the structure.
Structures are "Value" Types and classes are "Reference" Types - meaning when you pass a structure around you are passing the actual data, but when you pass a class around you are passing in a pointer to the data. My suggestion of passing the structure in ByRef (or just "ref" in C#) means that it will pass in a pointer to the structure - and equally by changing it to be a class instead of a structure you have achieved the same thing, as classes always get a pointer to them passed in (if you were to pass in a class ByRef then you would be using a pointer to a pointer).
You can't always use your method of just changing the structure to a class in every scenario, which is why I'm explaining all this
Glad to hear it is all working anyway! I'm going to be making something very similar in the near future so I'm sure this will all come in handy
Last edited by chris128; Jun 23rd, 2011 at 03:53 PM.
Re: Redirect Process Input/Output with Windows API
Hi Chris,
Actually, before I started messing around with everything, the only thing I did was try to pass the structure byref to the API function. This didn't work either. It may be though that the class for the SecurityDescriptor that I found is what was causing the problem. I don't know but I got it working, lol. Good to know about classes being entirely passed by reference and structures by value. I'm sure I read that already at some point but I forgot:P
Now I've realized why I had 2 separate executables for the server side. The function CreateProcessWithLogonW doesn't work properly from a processes launched by the local SYSTEM account but obtaining the currently logged on users security token first and launching a second "server type" processes embedded into the original server allows you to call CreateProcessWithLogonW under that users account, no matter if they have admin rights or not, and allows you to launch an application as another domain user.
If you have any suggestions for as to why I can't use this function under the SYSTEM account, please let me know. I'm not going to use that code provided to obtain the current users security token.
Re: Redirect Process Input/Output with Windows API
Don't use CreateProcessWithLogon then, use CreateProcessAsUser - this definitely works from a service running as Local System on Windows 7 as I used it the other day. No idea how well it works on XP though.
Re: Redirect Process Input/Output with Windows API
Hi Chris,
I tried your suggestion of using CreateProcessAsUser. It seems that it works perfectly fine to launch an interactive process on the remote desktop from the SYSTEM account but as soon as I try re-directing the standard output and input, etc, the process starts and then ends fairly quick with a startup code of 0 and an exit code of 0. The redirection of the output works perfectly fine use CreateProcess. Any ideas? I want to be able to launch the process interactive for use on the remote system and non-interactive, in which it re-directs the output to my named pipe back to the client. Very strange.
Re: Redirect Process Input/Output with Windows API
I think I recall having a similar problem when I was writing the code in the original post in this thread, I'm sure it was something to do with the handles to the named pipe being inherited (or not being inherited) by the child process. Sorry I can't give you anything more specific than that...
EDIT:
I think that's what this bit of the code was for:
vb.net Code:
'Duplicate the "write end" handle for the input pipe and make the duplicated handle non inheritable
If Not WindowsAPIs.DuplicateHandle(New HandleRef(Me, Process.GetCurrentProcess.Handle), TmpWriteInputHandle, _
New HandleRef(Me, Process.GetCurrentProcess.Handle), CurrentInputHandle, 0, False, WindowsAPIs.DUPLICATE_SAME_ACCESS) Then
Throw New System.ComponentModel.Win32Exception
End If
'Duplicate the "read end" handle for the output pipe and make the duplicated handle non inheritable
If Not WindowsAPIs.DuplicateHandle(New HandleRef(Me, Process.GetCurrentProcess.Handle), TmpReadOutputHandle, _
New HandleRef(Me, Process.GetCurrentProcess.Handle), CurrentOutputHandle, 0, False, WindowsAPIs.DUPLICATE_SAME_ACCESS) Then
Throw New System.ComponentModel.Win32Exception
End If
'Close the original handles we got from CreatePipe before we start the process so that it does
Re: Redirect Process Input/Output with Windows API
Hi Chris,
I already have the duplication of the handles in place in the same manor. I'm going to try this actually and see if it works. Very strange because the same code works fine with just CreateProcess.
1. use WTSGetActiveConsoleSessionId to get the ID of the current active Windows session at the console (i.e. the machine keyboard and display, as opposed to WTS sessions).
2. use WTSQueryUserToken to get the token for that session.
3. use DuplicateTokenEx(hToken,MAXIMUM_ALLOWED,NULL,SecurityIdentification,TokenPrimary, &hTokenDup) to duplicate that token.
4. use CreateEnvironmentBlock to create an environment that you will be passing to the process.
5. use CreateProcessAsUser with the duplicated token and the created environment. Actually, we use CreateProcessAsUserW, since the A version had some sort of bug on some older systems.
6. Don't forget to CloseHandle on the various tokens, etc, and to DestroyEnvironmentBlock the environment.
Re: Redirect Process Input/Output with Windows API
Hi Chris,
After 3 days of messing around with this, I finally got CreateProcessAsUser to launch a process as another domain user under the system account and can perform this operation interactively and non-interactively.
Code:
IntPtr hProcessToken = IntPtr.Zero;
TOKEN_PRIVILEGES tp = new TOKEN_PRIVILEGES();
tp.Privileges = new LUID_AND_ATTRIBUTES[1];
Result = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, ref hProcessToken);
if (!Result | hProcessToken == IntPtr.Zero)
Console.WriteLine("OpenProcessToken Failed: " + Marshal.GetLastWin32Error());
Result = LookupPrivilegeValue(null, SE_TCB_NAME, ref tp.Privileges[0].Luid);
if (!Result)
Console.WriteLine("LookupPrivilegeValue Failed: " + Marshal.GetLastWin32Error());
tp.PrivilegeCount = 1;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
Result = AdjustTokenPrivileges(hProcessToken, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
if (!Result)
Console.WriteLine("AdjustTokenPrivileges Failed: " + Marshal.GetLastWin32Error());
Result = LogonUser(p.Process.UserName.Split('\\')[1], p.Process.UserName.Split('\\')[0], p.Process.Password, (int)Logon32Type.Interactive, 0, out hProcessToken);
Result = CreateProcessAsUserW(hProcessToken, Process, string.Empty, SA, SA, true, (UInt32)32, IntPtr.Zero, System.IO.Directory.GetCurrentDirectory(), si, ref ProcessInfo);
Re: Redirect Process Input/Output with Windows API
Hi Chris,
And now I've finally got the option to launch the process as the currently logged in user working interactively and non-interactively.
Code:
uint ConsoleSessionId = WTSGetActiveConsoleSessionId();
IntPtr lpBuffer = IntPtr.Zero;
int Count = 0 ;
//IntPtr i;
Result = WTSQueryUserToken(ConsoleSessionId, out UserToken);
if (!Result)
Console.WriteLine("WTSQueryUserToken Failed: " + Marshal.GetLastWin32Error());
//If no token obtained then no one is logged onto the console. Check for active remote desktop session.
if (UserToken == IntPtr.Zero)
{
Result = Convert.ToBoolean(WTSEnumerateSessions(IntPtr.Zero, 0, 1, ref lpBuffer, ref Count));
int dataSize = Marshal.SizeOf(typeof(WTS_SESSION_INFO));
Int64 current = (int)lpBuffer;
if (Result)
{
for (int i = 0; i < Count; i++)
{
WTS_SESSION_INFO session = (WTS_SESSION_INFO)Marshal.PtrToStructure((IntPtr)current, typeof(WTS_SESSION_INFO));
current += dataSize;
if (session.State == WTS_CONNECTSTATE_CLASS.WTSActive)
Result = WTSQueryUserToken((uint)session.SessionID, out UserToken);
if (!Result)
Console.WriteLine("WTSQueryUserToken Failed: " + Marshal.GetLastWin32Error());
}
WTSFreeMemory(lpBuffer);
}
Now I can complete the easy stuff and soon I'll have a library available for use within anyone else's .Net application that functions just like PSEXEC on WinXP machines. I haven't had a chance to test on any newer OS's yet but this is working perfectly now without requiring the use of a second executable.
Re: Redirect Process Input/Output with Windows API
Cool, glad to hear you got it all working You may find you run into problems on Vista/Win7 though as services work a bit differently in that they all run in a dedicated isolated session (session 0). Let me know how it goes though
Re: Redirect Process Input/Output with Windows API
This is the reason why I created a second executable to run with the server service to launch a new gui application as a different user. Now I have to do this again.
Re: Redirect Process Input/Output with Windows API
I dont see why you need a second executable though, I mean why launch that second executable instead of just launching whatever process that executable is going to launch directly? The way I see it you either do this:
Service.exe -> [USER'S SESSION] -> Launcher.exe -> TargetProgram.exe
or just do this:
Service.exe -> [USER'S SESSION] -> TargetProgram.exe
Unless I'm missing something... I know I managed to get the second approach working on Windows 7 without a problem. In fact launching a GUI app in the user's session directly from a service was easier than having the service launch a command line app that then launched the GUI app in the user's session because of console inheritance issues.
Re: Redirect Process Input/Output with Windows API
Service.exe -> [CURRENTLY LOGGED IN USER's SESSION]-> TargetGUIApplication.exe works fine.
Service.exe -> [LOGONUSER ALTERNATE CREDENTIALS]->TargetGUIApplication.exe does not work. It launches the program it shows up transparent and you can't use the GUI application.
Service.exe -> [LOGONUSER ALTERNATE CREDENTIALS]->TargetConsoleApplication.exe works perfectly fine.
It seems that Service processes running as SYSTEM can't properly launch GUI applications interactively so therefore I will have to do...
Re: Redirect Process Input/Output with Windows API
Hey Chris do you know off hand what character string would be used to send a return code to the stdin without specifying a command first. I currently use command + "\r\n" + "\r" but remOving the command prefix doesn't send a new carriage return.
Re: Redirect Process Input/Output with Windows API
Lol sorry I'm in training at work right now. In your examPle to redirect input and output, the writefile function to send input to the process has a carriage return and a line feed followed by another carriage return suffixing the string to send to the process.
Re: Redirect Process Input/Output with Windows API
Yeah but I don't get what you mean when you say "send a return code to stdin". If you want to send a number to it then just send it as a string - but I'm assuming you already know that so I think I'm missing something
Re: Redirect Process Input/Output with Windows API
Ok, I'm back at my desk now. What I was trying to say is how can I send just a single carriage return to the stdin handle without any actual data.
Code:
public static void SendInput(string message, ref RemoteProcessPipes.CommandPipeData p)
{
if (p.CurrentProcessHandle != null && !p.stdIn.IsClosed)
{
byte[] MessageBytes = Encoding.GetEncoding(850).GetBytes(message + "\r\n" + "\r");
uint BytesWriten = 0;
if (!WriteFile(p.stdIn, MessageBytes, (uint)MessageBytes.Length - 1, ref BytesWriten, 0))
OutPipe.Connect(@"\\" + p.ClientHostName + @"\pipe\nRPInPipe" + p.Index.ToString(), "There was a problem sending input to the process. The last error reported was: " + new System.ComponentModel.Win32Exception().Message);
p.ThreadSignal.Set();
}
else
OutPipe.Connect(@"\\" + p.ClientHostName + @"\pipe\nRPInPipe" + p.Index.ToString(), "No process to send input to");
}
as you can see, the message is converted into bytes with a \r\n ,"vbcrlf", + a \r, "vbcr", suffixing the message. What if I just want to send the carriage return only. For instance, if the remote process is using a Console.ReadLine(), waiting for a carriage return, I want to send just the "\r\n" + "\r" but it doesn't seem to work.
Re: Redirect Process Input/Output with Windows API
LoL, Ok, I'm gonna try to figure this one out then. Almost out of time for the day, lol. I switched to C# mostly because every job I look for out their in relation to programming are looking for C# .Net programmers. Not too many VB programmer positions around here. At least if I know both of them, and master 1 of them, I should be good
Re: Redirect Process Input/Output with Windows API
Yeah I was only joking lol I have the luxury of working for myself (when it comes to programming anyway) so I can use whatever language I want, but if I was thinking of going for a programming job I would certainly learn C#
I'm assuming that this is more a problem with the service executable rather than the way I'm trying to start the process? Do you have any ideas because I've found way to many google results for this error without any solutions. Is it because the windows service is trying to be run with the interactive service option turned on?