Reagan: CreateProcess()?

okibi okibi at ratedo.com
Wed Sep 26 04:22:54 PDT 2007


Firstly, this only works on Windows, which is ok as system() doesn't open a terminal window on Linux.

The problem is that I'm hitting a batch file. When I set the program to point to cmd.exe, it will cause a command prompt window to open to run the command, so back to square one.

Clay Smith Wrote:

> The globals file is not necessary, just replace globals.programDir with 
> the location of the program directory as a char[].
> 
> execProcess(char[] program, char[] args, bool requireExitCode=true)
> 
> you don't need to run from cmd prompt to set program arguments, just do
> 
> execProcess("C:\svn\svn.exe", "co svn.dsource.org");
> 
> For batch scripts, use C:\systemwhatever\cmd.exe as program name and 
> batch.bat as the argument, that is supposed to work.
> 
> ~ Clay
> 
> okibi wrote:
> > Well, I can take out the import and comment out off the directory settings and the function works, however I need to give the full path of the command. 
> > 
> > However, it won't let me run batch scripts through the function at all. And for commands that take arguments, I seem to need to send it through a cmd prompt, which opens a window obviously. The only thing that really helped was the ability to choose whether to wait for the exit code or not.
> > 
> > Is the fact that the directory stuff is missing as well as the globals file causing this issue?
> > 
> > thanks!
> > 
> > okibi Wrote:
> > 
> >> The globals module is missing. Where can I find it?
> >>
> >> Thanks!
> >>
> >> Clay Smith Wrote:
> >>
> >>> okibi wrote:
> >>>> Hey Reagan,
> >>>>
> >>>> I took your suggestion about getting system() to run without a window by creating a CreateProcess(). I looked at your example on:
> >>>>
> >>>> http://www.digitalmars.com/d/archives/digitalmars/D/29556.html
> >>>>
> >>>> I can't get it to compile! I'm getting an error for expecting type ulong on line 107 in your pipestream.d file.
> >>>>
> >>>> Any ideas?
> >>>>
> >>>> Thanks!
> >>> Here you go:
> >>>
> >>> Windows info:
> >>> http://paste.dprogramming.com/dptyg7pt.php
> >>>
> >>> Create Process:
> >>> http://paste.dprogramming.com/dpsgva0j.php
> >>>
> >>> You can use execProcess or my ChildProcesses class.
> >>>
> >>> ~ Clay
> > 



More information about the Digitalmars-d-learn mailing list