ShowCommands ();
/* Set COMSPEC environment variable */
-#ifndef __REACTOS__
+/* #ifndef __REACTOS__ */
if (argv)
+ {
+ ConErrPrintf("Argv[0]: '%s'", argv[0]);
SetEnvironmentVariable (_T("COMSPEC"), argv[0]);
-#endif
+ }
+/* #endif */
/* add ctrl handler */
#if 0
#define D_OFF "off"
-#define CHECKPOINT ConErrPrintf("%s:%d\n",__FILE__,__LINE__);
-
/* Prototypes for CMD.C */
extern HANDLE hOut;
INT cmd_set (LPTSTR, LPTSTR);
+/* Prototypes for START.C */
+INT cmd_start (LPTSTR, LPTSTR);
+
+
/* Prototypes for TIME.C */
INT cmd_time (LPTSTR, LPTSTR);
{_T("shift"), CMD_BATCHONLY, cmd_shift},
+#ifdef INCLUDE_CMD_START
+ {_T("start"), 0, cmd_start},
+#endif
+
#ifdef INCLUDE_CMD_TIME
{_T("time"), 0, cmd_time},
#endif
/* JPP 20 Jul 1998 - define DEBUG to add debugging code */
-#define DEBUG
+/*#define DEBUG */
/* Define to enable the alias command, and aliases.*/
#define INCLUDE_CMD_RMDIR
#define INCLUDE_CMD_RENAME
#define INCLUDE_CMD_SET
+#define INCLUDE_CMD_START
#define INCLUDE_CMD_TIME
#define INCLUDE_CMD_TITLE
#define INCLUDE_CMD_TYPE
chcp.o cls.o cmdinput.o cmdtable.o color.o console.o copy.o date.o \
del.o dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o \
history.o if.o internal.o label.o locale.o misc.o move.o path.o \
- pause.o prompt.o redir.o ren.o set.o shift.o time.o title.o type.o \
- ver.o verify.o vol.o where.o
+ pause.o prompt.o redir.o ren.o set.o shift.o start.o time.o title.o \
+ type.o ver.o verify.o vol.o where.o
LIBS= ../../lib/kernel32/kernel32.a ../../lib/crtdll/crtdll.a
ren.obj \
set.obj \
shift.obj \
+ start.obj \
time.obj \
type.obj \
ver.obj \
# MAIN
-# What about this implicid rule?
-# It should compile all c files.
-# (To test this, uncomment the following two lines.) EK
-#.c.obj:
-# $(CC) $(CFLAGS) $<
+.c.obj:
+ $(CC) $(CFLAGS) $<
$(TARGET).exe: $(OBJS)
$(LD) $(LFLAGS) $(OBJS)
-# MODULES
-
-alias.obj: alias.c
- $(CC) $(CFLAGS) alias.c
-
-attrib.obj: attrib.c
- $(CC) $(CFLAGS) attrib.c
-
-batch.obj: batch.c
- $(CC) $(CFLAGS) batch.c
-
-beep.obj: beep.c
- $(CC) $(CFLAGS) beep.c
-
-call.obj: call.c
- $(CC) $(CFLAGS) call.c
-
-cls.obj: cls.c
- $(CC) $(CFLAGS) cls.c
-
-cmd.obj: cmd.c
- $(CC) $(CFLAGS) cmd.c
-
-cmdinput.obj: cmdinput.c
- $(CC) $(CFLAGS) cmdinput.c
-
-cmdtable.obj: cmdtable.c
- $(CC) $(CFLAGS) cmdtable.c
-
-color.obj: color.c
- $(CC) $(CFLAGS) color.c
-
-console.obj: console.c
- $(CC) $(CFLAGS) console.c
-
-copy.obj: copy.c
- $(CC) $(CFLAGS) copy.c
-
-date.obj: date.c
- $(CC) $(CFLAGS) date.c
-
-del.obj: del.c
- $(CC) $(CFLAGS) del.c
-
-dir.obj: dir.c
- $(CC) $(CFLAGS) dir.c
-
-dirstack.obj: dirstack.c
- $(CC) $(CFLAGS) dirstack.c
-
-echo.obj: echo.c
- $(CC) $(CFLAGS) echo.c
-
-error.obj: error.c
- $(CC) $(CFLAGS) error.c
-
-filecomp.obj: filecomp.c
- $(CC) $(CFLAGS) filecomp.c
-
-for.obj: for.c
- $(CC) $(CFLAGS) for.c
-
-goto.obj: goto.c
- $(CC) $(CFLAGS) goto.c
-
-history.obj: history.c
- $(CC) $(CFLAGS) history.c
-
-if.obj: if.c
- $(CC) $(CFLAGS) if.c
-
-internal.obj: internal.c
- $(CC) $(CFLAGS) internal.c
-
-label.obj: label.c
- $(CC) $(CFLAGS) label.c
-
-locale.obj: locale.c
- $(CC) $(CFLAGS) locale.c
-
-misc.obj: misc.c
- $(CC) $(CFLAGS) misc.c
-
-move.obj: move.c
- $(CC) $(CFLAGS) move.c
-
-path.obj: path.c
- $(CC) $(CFLAGS) path.c
-
-pause.obj: pause.c
- $(CC) $(CFLAGS) pause.c
-
-prompt.obj: prompt.c
- $(CC) $(CFLAGS) prompt.c
-
-redir.obj: redir.c
- $(CC) $(CFLAGS) redir.c
-
-ren.obj: ren.c
- $(CC) $(CFLAGS) ren.c
-
-set.obj: set.c
- $(CC) $(CFLAGS) set.c
-
-shift.obj: shift.c
- $(CC) $(CFLAGS) shift.c
-
-time.obj: time.c
- $(CC) $(CFLAGS) time.c
-
-type.obj: type.c
- $(CC) $(CFLAGS) type.c
-
-ver.obj: ver.c
- $(CC) $(CFLAGS) ver.c
-
-verify.obj: verify.c
- $(CC) $(CFLAGS) verify.c
-
-vol.obj: vol.c
- $(CC) $(CFLAGS) vol.c
-
-where.obj: where.c
- $(CC) $(CFLAGS) where.c
-
#EOF
--- /dev/null
+/*
+ * START.C - start internal command.
+ *
+ *
+ * History:
+ *
+ * 24-Jul-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
+ * Started.
+ */
+
+#include "config.h"
+
+#ifdef INCLUDE_CMD_START
+#include <windows.h>
+#include <tchar.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "cmd.h"
+
+
+INT cmd_start (LPTSTR first, LPTSTR rest)
+{
+ TCHAR szFullName[MAX_PATH];
+ BOOL bWait = FALSE;
+
+ if (_tcsncmp (rest, _T("/?"), 2) == 0)
+ {
+ ConOutPuts (_T("Starts a command.\n\n"
+ "START command \n\n"
+ " command Specifies the command to run.\n\n"
+ "At the moment all commands are started asynchronously.\n"));
+
+ return 0;
+ }
+
+ /* check for a drive change */
+ if (!_tcscmp (first + 1, _T(":")) && _istalpha (*first))
+ {
+ TCHAR szPath[MAX_PATH];
+
+ _tcscpy (szPath, _T("A:"));
+ szPath[0] = _totupper (*first);
+ SetCurrentDirectory (szPath);
+ GetCurrentDirectory (MAX_PATH, szPath);
+ if (szPath[0] != (TCHAR)_totupper (*first))
+ ConErrPuts (INVALIDDRIVE);
+
+ return 0;
+ }
+
+ /* get the PATH environment variable and parse it */
+ /* search the PATH environment variable for the binary */
+ if (!SearchForExecutable (first, szFullName))
+ {
+ error_bad_command ();
+ return 1;
+ }
+
+ /* check if this is a .BAT or .CMD file */
+ if (!_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".bat")) ||
+ !_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".cmd")))
+ {
+#ifdef _DEBUG
+ DebugPrintf ("[BATCH: %s %s]\n", szFullName, rest);
+#endif
+ ConErrPuts (_T("No batch support at the moment!"));
+ }
+ else
+ {
+ /* exec the program */
+ TCHAR szFullCmdLine [1024];
+ PROCESS_INFORMATION prci;
+ STARTUPINFO stui;
+
+#ifdef _DEBUG
+ DebugPrintf ("[EXEC: %s %s]\n", szFullName, rest);
+#endif
+ /* build command line for CreateProcess() */
+ _tcscpy (szFullCmdLine, szFullName);
+ _tcscat (szFullCmdLine, _T(" "));
+ _tcscat (szFullCmdLine, rest);
+
+ /* fill startup info */
+ memset (&stui, 0, sizeof (STARTUPINFO));
+ stui.cb = sizeof (STARTUPINFO);
+ stui.dwFlags = STARTF_USESHOWWINDOW;
+ stui.wShowWindow = SW_SHOWDEFAULT;
+
+ if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
+ 0, NULL, NULL, &stui, &prci))
+ {
+ if (bWait)
+ {
+ DWORD dwExitCode;
+ WaitForSingleObject (prci.hProcess, INFINITE);
+ GetExitCodeProcess (prci.hProcess, &dwExitCode);
+ nErrorLevel = (INT)dwExitCode;
+ CloseHandle (prci.hThread);
+ CloseHandle (prci.hProcess);
+ }
+ }
+ else
+ {
+ ErrorMessage (GetLastError (),
+ "Error executing CreateProcess()!!\n");
+ }
+ }
+
+ return 0;
+}
+
+#endif
+
+/* EOF */
#define D_OFF "off"
-#define CHECKPOINT ConErrPrintf("%s:%d\n",__FILE__,__LINE__);
-
/* Prototypes for CMD.C */
extern HANDLE hOut;
INT cmd_set (LPTSTR, LPTSTR);
+/* Prototypes for START.C */
+INT cmd_start (LPTSTR, LPTSTR);
+
+
/* Prototypes for TIME.C */
INT cmd_time (LPTSTR, LPTSTR);
{_T("shift"), CMD_BATCHONLY, cmd_shift},
+#ifdef INCLUDE_CMD_START
+ {_T("start"), 0, cmd_start},
+#endif
+
#ifdef INCLUDE_CMD_TIME
{_T("time"), 0, cmd_time},
#endif
#ifndef _CONFIG_H_INCLUDED_
#define _CONFIG_H_INCLUDED_
-//#ifndef __REACTOS__
+#ifndef __REACTOS__
#define WIN32_LEAN_AND_MEAN
-//#endif /* __REACTOS__ */
-
-
-//#ifdef UNICODE
-//#define _T(x) L##x
-//#else
-//#define _T(x) x
-//#endif
-
+#endif /* __REACTOS__ */
/* JPP 20 Jul 1998 - define DEBUG to add debugging code */
-#define DEBUG
+/*#define DEBUG */
/* Define to enable the alias command, and aliases.*/
#define INCLUDE_CMD_RMDIR
#define INCLUDE_CMD_RENAME
#define INCLUDE_CMD_SET
+#define INCLUDE_CMD_START
#define INCLUDE_CMD_TIME
#define INCLUDE_CMD_TITLE
#define INCLUDE_CMD_TYPE
chcp.o cls.o cmdinput.o cmdtable.o color.o console.o copy.o date.o \
del.o dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o \
history.o if.o internal.o label.o locale.o misc.o move.o path.o \
- pause.o prompt.o redir.o ren.o set.o shift.o time.o title.o type.o \
- ver.o verify.o vol.o where.o
+ pause.o prompt.o redir.o ren.o set.o shift.o start.o time.o title.o \
+ type.o ver.o verify.o vol.o where.o
CLEAN_FILES = *.o cmd.exe cmd.sym
--- /dev/null
+/*
+ * START.C - start internal command.
+ *
+ *
+ * History:
+ *
+ * 24-Jul-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
+ * Started.
+ */
+
+#include "config.h"
+
+#ifdef INCLUDE_CMD_START
+#include <windows.h>
+#include <tchar.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "cmd.h"
+
+
+INT cmd_start (LPTSTR first, LPTSTR rest)
+{
+ TCHAR szFullName[MAX_PATH];
+ BOOL bWait = FALSE;
+
+ if (_tcsncmp (rest, _T("/?"), 2) == 0)
+ {
+ ConOutPuts (_T("Starts a command.\n\n"
+ "START command \n\n"
+ " command Specifies the command to run.\n\n"
+ "At the moment all commands are started asynchronously.\n"));
+
+ return 0;
+ }
+
+ /* check for a drive change */
+ if (!_tcscmp (first + 1, _T(":")) && _istalpha (*first))
+ {
+ TCHAR szPath[MAX_PATH];
+
+ _tcscpy (szPath, _T("A:"));
+ szPath[0] = _totupper (*first);
+ SetCurrentDirectory (szPath);
+ GetCurrentDirectory (MAX_PATH, szPath);
+ if (szPath[0] != (TCHAR)_totupper (*first))
+ ConErrPuts (INVALIDDRIVE);
+
+ return 0;
+ }
+
+ /* get the PATH environment variable and parse it */
+ /* search the PATH environment variable for the binary */
+ if (!SearchForExecutable (first, szFullName))
+ {
+ error_bad_command ();
+ return 1;
+ }
+
+ /* check if this is a .BAT or .CMD file */
+ if (!_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".bat")) ||
+ !_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".cmd")))
+ {
+#ifdef _DEBUG
+ DebugPrintf ("[BATCH: %s %s]\n", szFullName, rest);
+#endif
+ ConErrPuts (_T("No batch support at the moment!"));
+ }
+ else
+ {
+ /* exec the program */
+ TCHAR szFullCmdLine [1024];
+ PROCESS_INFORMATION prci;
+ STARTUPINFO stui;
+
+#ifdef _DEBUG
+ DebugPrintf ("[EXEC: %s %s]\n", szFullName, rest);
+#endif
+ /* build command line for CreateProcess() */
+ _tcscpy (szFullCmdLine, szFullName);
+ _tcscat (szFullCmdLine, _T(" "));
+ _tcscat (szFullCmdLine, rest);
+
+ /* fill startup info */
+ memset (&stui, 0, sizeof (STARTUPINFO));
+ stui.cb = sizeof (STARTUPINFO);
+ stui.dwFlags = STARTF_USESHOWWINDOW;
+ stui.wShowWindow = SW_SHOWDEFAULT;
+
+ if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
+ 0, NULL, NULL, &stui, &prci))
+ {
+ if (bWait)
+ {
+ DWORD dwExitCode;
+ WaitForSingleObject (prci.hProcess, INFINITE);
+ GetExitCodeProcess (prci.hProcess, &dwExitCode);
+ nErrorLevel = (INT)dwExitCode;
+ CloseHandle (prci.hThread);
+ CloseHandle (prci.hProcess);
+ }
+ }
+ else
+ {
+ ErrorMessage (GetLastError (),
+ "Error executing CreateProcess()!!\n");
+ }
+ }
+
+ return 0;
+}
+
+#endif
+
+/* EOF */