mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:03:00 +00:00
Added simple START command.
svn path=/trunk/; revision=605
This commit is contained in:
parent
0063a30376
commit
e3c471cf82
12 changed files with 266 additions and 152 deletions
|
@ -939,10 +939,13 @@ static VOID Initialize (int argc, char *argv[])
|
|||
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
|
||||
|
|
|
@ -65,8 +65,6 @@
|
|||
#define D_OFF "off"
|
||||
|
||||
|
||||
#define CHECKPOINT ConErrPrintf("%s:%d\n",__FILE__,__LINE__);
|
||||
|
||||
|
||||
/* Prototypes for CMD.C */
|
||||
extern HANDLE hOut;
|
||||
|
@ -300,6 +298,10 @@ INT cmd_rename (LPTSTR, LPTSTR);
|
|||
INT cmd_set (LPTSTR, LPTSTR);
|
||||
|
||||
|
||||
/* Prototypes for START.C */
|
||||
INT cmd_start (LPTSTR, LPTSTR);
|
||||
|
||||
|
||||
/* Prototypes for TIME.C */
|
||||
INT cmd_time (LPTSTR, LPTSTR);
|
||||
|
||||
|
|
|
@ -169,6 +169,10 @@ COMMAND cmds[] =
|
|||
|
||||
{_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
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
|
||||
/* JPP 20 Jul 1998 - define DEBUG to add debugging code */
|
||||
#define DEBUG
|
||||
/*#define DEBUG */
|
||||
|
||||
|
||||
/* Define to enable the alias command, and aliases.*/
|
||||
|
@ -74,6 +74,7 @@
|
|||
#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
|
||||
|
|
|
@ -8,8 +8,8 @@ OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o \
|
|||
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
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ OBJS=alias.obj \
|
|||
ren.obj \
|
||||
set.obj \
|
||||
shift.obj \
|
||||
start.obj \
|
||||
time.obj \
|
||||
type.obj \
|
||||
ver.obj \
|
||||
|
@ -57,138 +58,10 @@ OBJS=alias.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
|
||||
|
|
116
reactos/apps/utils/cmd/start.c
Normal file
116
reactos/apps/utils/cmd/start.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* 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 */
|
|
@ -65,8 +65,6 @@
|
|||
#define D_OFF "off"
|
||||
|
||||
|
||||
#define CHECKPOINT ConErrPrintf("%s:%d\n",__FILE__,__LINE__);
|
||||
|
||||
|
||||
/* Prototypes for CMD.C */
|
||||
extern HANDLE hOut;
|
||||
|
@ -300,6 +298,10 @@ INT cmd_rename (LPTSTR, LPTSTR);
|
|||
INT cmd_set (LPTSTR, LPTSTR);
|
||||
|
||||
|
||||
/* Prototypes for START.C */
|
||||
INT cmd_start (LPTSTR, LPTSTR);
|
||||
|
||||
|
||||
/* Prototypes for TIME.C */
|
||||
INT cmd_time (LPTSTR, LPTSTR);
|
||||
|
||||
|
|
|
@ -169,6 +169,10 @@ COMMAND cmds[] =
|
|||
|
||||
{_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
|
||||
|
|
|
@ -14,21 +14,13 @@
|
|||
#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.*/
|
||||
|
@ -82,6 +74,7 @@
|
|||
#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
|
||||
|
|
|
@ -8,8 +8,8 @@ OBJECTS = cmd.o attrib.o alias.o batch.o beep.o call.o \
|
|||
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
|
||||
|
||||
|
|
116
rosapps/cmd/start.c
Normal file
116
rosapps/cmd/start.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* 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 */
|
Loading…
Add table
Add a link
Reference in a new issue