mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:15:58 +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
|
@ -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