Page 1 of 1

I want to make StartProcess

Posted: 28 Jun 2012 10:50
by einstein1969
hi,

I need to realize a function for start a process with more controll than "start"

I found that is possible via vbscript with WMI control.

I want realize with your help a generic procedure , an wrapper?, for start a process.

the process be started with a priority and a parameter to hide the window, and more.

I start from here

Code: Select all

:Create_process      [in]   string CommandLine,
::         [in]   string CurrentDirectory,
::         [in]   uint32 CreateFlags;
::         [in]   string EnvironmentVariables[];
::         [in]   uint16 ErrorMode;
::         [in]   uint32 FillAttribute;
::         [in]   uint32 PriorityClass;
::         [in]   uint16 ShowWindow;
::         [in]   string Title;
::         [in]   string WinstationDesktop;
::         [in]   uint32 X;
::         [in]   uint32 XCountChars;
::         [in]   uint32 XSize;
::         [in]   uint32 Y;
::         [in]   uint32 YCountChars;
::         [in]   uint32 YSize; 
::         [out]   uint32 ProcessId

REM REF. http://msdn.microsoft.com/en-us/library/windows/desktop/aa389388%28v=vs.85%29.aspx


:: CommandLine [in]
::    Command line to execute. The system adds a null character to the command line, trimming the string if necessary, to indicate which file was actually used.

:: CurrentDirectory [in]
::    Current drive and directory for the child process. The string requires that the current directory resolves to a known path. A user can specify an absolute path or a path relative to the current working directory. If this parameter is NULL, ::the new process will have the same path as the calling process. This option is provided primarily for shells that must ::start an application and specify the application's initial drive and working directory.


::    The startup configuration of a Windows process. [in]

::CreateFlags
::EnvironmentVariables
::ErrorMode
::FillAttribute

::PriorityClass [in]
::   The PriorityClass property controls the priority class of the new process (used to determine the scheduling priorities of the threads in the process).  If the PriorityClass property is left null, the priority class defaults to Normal unless the priority class of the creating process is Idle or Below_Normal. In these cases, the child process receives the default priority class of the calling process.


::ShowWindow
::   The ShowWindow property specifies how the window is to be displayed to the user.

::Title

::WinstationDesktop


::X
::XCountChars
::XSize

::Y
::YCountChars
::YSize


:: ProcessId [out]
::    Global process identifier that can be used to identify a process. The value is valid from the time the process is created until the time the process is terminated.


:: Return Value
::   0   Successful Completion
::   2   Access Denied
::   3   Insufficient Privilege
::   8   Unknown failure
::   9   Path Not Found
::   21   Invalid Parameter


goto :eof

Re: I want to make StartProcess

Posted: 30 Jun 2012 05:31
by Aacini
I see several problems trying to do that. Your starter must duplicate the Window size/appareance/font/etc. of START command in multiple details, otherwise posterior cmd.exe commands may fail or not display their results correctly. I think that just duplicate the functionality of START command may be a hard job. The documentation at that site is poor and the users complain of multiple problems. Did you read that comments?

On the other hand, most of your requirements are already managed by cmd.exe commands, like CommandLine, CurrentDirectory, EnvironmentVariables, PriorityClass, Title, etc. Other requirements may be solved via auxiliary .exe programs. For example, ShowWindow and window size and position can be managed with my Window.exe auxiliary program.

Perhaps an easier solution would be to develop a couple small auxiliary programs that provide the missed functionality you need. What exactly are the points you are trying to solve with your starter application?

Antonio

Re: I want to make StartProcess

Posted: 01 Jul 2012 14:46
by einstein1969
Thanks Antonio,

I saw your work, is exceptional. :shock:

Regarding the difficulty of creating this procedure agree with you that there are many dark sides, and little documentation. But some things do not serve, for example, font and window size. I think it is possible to use the defaults that are managed by the registry and the property "title".

I had not read the comments, but re-evaluates them well, some of them do not seem directly related to the above problems. For remote execution, there are other tools, or other appropriate solutions.

With regard to the priorities I still have some problems especially in conjunction with pipes. See this topic

The other features I need are (for now):

- Identification of the correct processes PID's (and children) involved in a pipe.
- Kill the processes involved for PID
- Hidden Start / Occultation of the next window (I could use your window.exe)
- Start the process with priority / Changing priorities for PID

einstein1969