-bool wxShell(const wxString& command)
-{
- wxChar *shell;
- if ((shell = wxGetenv(_T("COMSPEC"))) == NULL)
- shell = _T("\\CMD.EXE");
+bool wxShell(
+ const wxString& rCommand
+)
+{
+ wxChar* zShell = _T("CMD.EXE");
+ wxString sInputs;
+ STARTDATA SData = {0};
+ PSZ PgmTitle = "Command Shell";
+ APIRET rc;
+ PID vPid = 0;
+ ULONG ulSessID = 0;
+ UCHAR achObjBuf[256] = {0}; //error data if DosStart fails
+ RESULTCODES vResult;
+
+ SData.Length = sizeof(STARTDATA);
+ SData.Related = SSF_RELATED_INDEPENDENT;
+ SData.FgBg = SSF_FGBG_FORE;
+ SData.TraceOpt = SSF_TRACEOPT_NONE;
+ SData.PgmTitle = PgmTitle;
+ SData.PgmName = (char*)zShell;
+
+ sInputs = _T("/C ") + rCommand;
+ SData.PgmInputs = (BYTE*)sInputs.c_str();
+ SData.TermQ = 0;
+ SData.Environment = 0;
+ SData.InheritOpt = SSF_INHERTOPT_SHELL;
+ SData.SessionType = SSF_TYPE_WINDOWABLEVIO;
+ SData.IconFile = 0;
+ SData.PgmHandle = 0;
+ SData.PgmControl = SSF_CONTROL_VISIBLE | SSF_CONTROL_MAXIMIZE;
+ SData.InitXPos = 30;
+ SData.InitYPos = 40;
+ SData.InitXSize = 200;
+ SData.InitYSize = 140;
+ SData.Reserved = 0;
+ SData.ObjectBuffer = (char*)achObjBuf;
+ SData.ObjectBuffLen = (ULONG)sizeof(achObjBuf);
+
+ rc = ::DosStartSession(&SData, &ulSessID, &vPid);
+ if (rc == 0 || rc == 457) // NO_ERROR or SMG_START_IN_BACKGROUND
+ {
+ PTIB ptib;
+ PPIB ppib;