StartX v1.15 An application + source code to
call the CreateProcess API
Welcome to StartX, A very simple utility to allow you to call the CreateProcess
API from the command line.
Places where you might find StartX useful are in adding an Autorun.inf file to
your CD-R / DVR-R Discs. For example suppose you have a text file called readme.txt
on the root of your CD which you would like to run it automatically by displaying
it in Wordpad maximized whenever the user inserts the CD. All you need to do is
put StartX.exe, some ico file and the readme.txt files into the root directory and
create a autorun.inf file with the following contents:
[autorun]
open=StartX.exe /MAX "wordpad.exe readme.txt"
icon=youricon.ico
The more technically minded of you may say why is there a need to have this program
since you can use "start filename" on autorun CD's without any apparent
problems. The problem with this approach is that it does not work on versions of
Windows based on the NT kernel as "start" is implemented as an "Internal"
command in cmd.exe with the upshot that your CD's will not autorun on versions of
Windows based on the NT kernel. Using StartX will mean that your CD's will autorun
on all OS's which support it.
StartX includes a nearly full superset of the commands which the internal Windows
XP and later Start command provides. The full list is:
StartX ["title"] [/Dpath] [/MIN | /MAX | /HIDE] [/NOUI] [/SEPARATE
| /SHARED] [/PP] [/Uuser] [/Wpassword] [/Odomain] [/K[desktop]] [/Px,y] [/Scx1,cy1]
[/CScx2,cy2] [/FR] [/FG] [/FB] [/BR] [/BG] [/BB] [/FS] [/LP | /LNCO] [/LOW | /NORMAL
| /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/WAIT] [/B] [/RETURNERROR] [/AFFINITYx]
[/NODEx] [/PREVENTPINNING] [/TITLEISAPPID] [/TITLEISLINKNAME] [/UNTRUSTEDSOURCE]
["command/program parameters"]
The enclosed
zip file contains the StartX source code and a prebuilt version of StartX.
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
- The executable file itself, namely "StartX.exe" can be freely
redistributed by anyone.
Updates
v1.15 (27 May 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
v1.14 (5 April 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.13 (29 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
v1.12 (16 November 2019)
- Updated initialization of various structs to use C++ 11 list
initialization
v1.11 (1 June 2019)
- Updated copyright details.
- Updated the code to clean compile on VC 2019
v1.10 (17 October 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These
changes mean that the code will now only compile on VC 2017 or later.
v1.09 (5 December 2017)
- Updated copyright details
- Replaced NULL throughout the codebase with nullptr.
- Replaced BOOL throughout the codebase with bool.
- Replaced CString::operator LPC*STR() calls throughout the codebase with
CString::GetString calls
- GetNumaNodeProcessorMaskEx is now called directly rather than via
GetProcAddress. This means that the minimum supported version of Windows is
Windows 7.
- CMyCommandLineInfo::GetIdlPath has been reworked and renamed to
work with KNOWNFOLDERID values instead of CSIDL values.
v1.08 (5 June 2016)
- Updated documentation for the /TITLEISAPPID, /TITLEISLINKNAME & /UNTRUSTEDSOURCE
parameters. Thanks to Marc Kupper for reporting this issue.
- Updated documentation to remove double reference to /NOUI. Thanks to Marc
Kupper for reporting this issue.
- Removed documentation reference to /I command line parameter. Thanks to
Marc Kupper for reporting this issue.
- Updated documentation to refer to /MIN, /MAX & /HIDE as mutually exclusive.
Thanks to Marc Kupper for reporting this issue.
- Updated documentation to refer to /LP & /LNCO as mutually exclusive.
Thanks to Marc Kupper for reporting this issue.
- Updated documentation for parameters to be in the same order in the parameters
list and the description table. Thanks to Marc Kupper for reporting this issue.
- Added code to support the /REALTIME parameter. Thanks to Marc Kupper for
reporting this issue.
v1.07 (22 May 2016)
- Updated copyright details.
- Update the project settings to more modern defaults
- Updated the code to clean compile on VC 2010 - VC 2015
- CMyCommandLineInfo::GetIdlPath now calls ShGetFolderPath directly instead
of through GetProcAddress.
- Code now calls CreateProcessWithLogonW directly instead of through GetProcAddress
- Code now calls CredUIPromptForCredentials directly instead of through GetProcAddress
- Reviewed the documentation's description of all the CSIDL values and made
sure it was up to date.
- StartX now supports a /HIDE command line option.
- StartX now supports a /NODE command line option similiar to the internal
Start Windows command
- StartX now supports a /PREVENTPINNING command line option.
- StartX now supports a /TITLEISAPPID command line option.
- StartX now supports a /TITLEISLINKNAME command line option.
- StartX now supports a /UNTRUSTEDSOURCE command line option.
- The download now includes a number of precompiled binaries of StartX.exe.
In the ReleaseU directory is a Unicode x86 build while the ReleaseU64 directory
includes a Unicode x64 build.
- As of this version, the code is designed for VC 2010 or later. It will not
compile on earlier releases of VC.
v1.06 (11 November 2008)
- Code now compiles cleanly using Code Analysis (/analyze)
- Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
define
- The code has now been updated to support VC 2005 or later only.
- StartX can now set the process affinity mask via the new AFFINITY command
line option. The value you provide here is the value passed to SetProcessAffinityMask.
So for example if you wanted to limit the new process to only run on the 2nd
and 3rd CPU only of a computer then you would use the command line "/AFFINITY6".
i.e. 0x2 & 0x4. Probably the most common value you would use for this would
be "/AFFINITY1" which would limit the process to run on the first
CPU only. Please note that the value you provide on the command line should
be decimal and not hexadecimal. Thanks to "Cobus" for prompting this
update.
v1.05 (8 February 2008)
- Updated copyright details.
- Removed VC 6 style AppWizard comments from the code
- Updated the code to clean compile on VC 2008
- The code and shipped exe has been updated to take advantage of VC 2005 specific
coding techniques.
- In fact the shipped exe in the zip was compiled with VC 2005 SP1.
- CStartXApp::GetErrorMessage now uses the FORMAT_MESSAGE_IGNORE_INSERTS flag.
For more information please see Raymond Chen's blog at
http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx. Thanks
to Alexey Kuznetsov for reporting this issue.
v1.04 (17 July 2006)
- Updated copyright details.
- Optimized CMyCommandLineInfo constructor code
- Code now uses new C++ style casts rather than old style C casts where necessary.
- CSIDL folders parameter replacement now uses the value @CSIDLnumber@ instead
of just @number@. This avoids problems where you need to pass a real "@"
onto the application being controlled. Thanks to Ramon Hansman for reporting
this issue.
- Updated the documentation to use the same style as the web site.
- Replaced all calls to ZeroMemory with memset
- Code now securely deletes the domain, username and password strings once
they have been used.
- Updated the code to clean compile on VC 2005
- The code now requires the Platform SDK if compiled using VC 6.
- Code now uses SHGFP_TYPE_CURRENT instead of SHGFP_TYPE_DEFAULT when calling
SHGetFolderPath.
- Fixed a coding error where CStartXApp::InitInstance returned TRUE instead
of FALSE.
- CreateProcessWithLogonW is now used if a username is specified or if the
prompt password command line option is set.
v1.03 (19 August 2005)
- Error codes are now reported as a string by calling FormatMessage. Thanks
to Dennis Bareis for prompting this update.
- String resources which are displayed to the end user now use the format
IDP_...
v1.02 (20 December 2004)
- Now supports a /RETURNERROR command line parameter, which returns the error
code of the process being run. Setting this parameter implies using /WAIT. Thanks
to Tomasz Nowak for suggesting this addition.
v1.01 (20 August 2004)
- Now returns the error code back to the OS as returned from any failures
when calling the Win32 SDK calls which StartX uses.
- Now includes a /NOUI command line parameter, which suppresses any messages
boxes which can appear when an error occurs. Thanks to Trevor Hart for these
2 suggestions.
3 July 2004
- Now includes explicit info on the usage of the executable "StartX.exe"
in the documentation
v1.0 (29 January 2003)