I have a project that internally uses cmd /c "..."
to launch some small utilities that are part of the software package and developed by myself.
Today I realized about the existence of a /D
switch in cmd
:
/D Disable execution of AutoRun commands from registry (see below)
...
If /D was NOT specified on the command line, then when CMD.EXE starts, it
looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if
either or both are present, they are executed first.
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
I wonder if I should include such switch to avoid unintended behaviors (such as app injection, setting undesired env vars, etc), or if using this would carry me out more problems (such as unset system required variables, don't know).
Note: the reason why I'm using cmd
is due to problems I've had with UAC (both elevating or downgrading privileges) and other issues in the past with other methods, like CreateProcess
, that I think are far from the scope of this question.