mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[NETSH] Implement the exec command and fix script execution
This commit is contained in:
@@ -325,6 +325,26 @@ UpCommand(
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
ExecCommand(
|
||||
LPCWSTR pwszMachine,
|
||||
LPWSTR *argv,
|
||||
DWORD dwCurrentIndex,
|
||||
DWORD dwArgCount,
|
||||
DWORD dwFlags,
|
||||
LPCVOID pvData,
|
||||
BOOL *pbDone)
|
||||
{
|
||||
DPRINT("ExecCommand()\n");
|
||||
|
||||
if (dwArgCount - dwCurrentIndex != 1)
|
||||
return ERROR_INVALID_SYNTAX;
|
||||
|
||||
return RunScript(argv[dwCurrentIndex]);
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
ExitCommand(
|
||||
@@ -372,7 +392,7 @@ PopdCommand(
|
||||
DPRINT("PopdCommand()\n");
|
||||
|
||||
if (pContextStackHead == NULL)
|
||||
return 0;
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
pEntry = pContextStackHead;
|
||||
|
||||
@@ -412,7 +432,7 @@ PushdCommand(
|
||||
|
||||
pEntry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CONTEXT_STACK_ENTRY));
|
||||
if (pEntry == NULL)
|
||||
return 1;
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
pEntry->pContext = pCurrentContext;
|
||||
if (pContextStackHead == NULL)
|
||||
@@ -446,6 +466,7 @@ CreateRootContext(VOID)
|
||||
AddContextCommand(pRootContext, L"..", UpCommand, IDS_HLP_UP, IDS_HLP_UP_EX, 0);
|
||||
AddContextCommand(pRootContext, L"?", NULL, IDS_HLP_HELP, IDS_HLP_HELP_EX, 0);
|
||||
AddContextCommand(pRootContext, L"bye", ExitCommand, IDS_HLP_EXIT, IDS_HLP_EXIT_EX, 0);
|
||||
AddContextCommand(pRootContext, L"exec", ExecCommand, IDS_HLP_EXEC, IDS_HLP_EXEC_EX, 0);
|
||||
AddContextCommand(pRootContext, L"exit", ExitCommand, IDS_HLP_EXIT, IDS_HLP_EXIT_EX, 0);
|
||||
AddContextCommand(pRootContext, L"help", NULL, IDS_HLP_HELP, IDS_HLP_HELP_EX, 0);
|
||||
AddContextCommand(pRootContext, L"popd", PopdCommand, IDS_HLP_POPD, IDS_HLP_POPD_EX, 0);
|
||||
|
||||
@@ -208,8 +208,7 @@ InterpretCommand(
|
||||
dwError = pCommand->pfnCmdHandler(NULL, argv, dwArgIndex, dwArgCount, 0, NULL, bDone);
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
{
|
||||
ConPrintf(StdOut, L"Error: %lu\n\n", dwError);
|
||||
ConResPrintf(StdOut, pCommand->dwCmdHlpToken);
|
||||
ConPrintf(StdOut, L"Commnand: %S Error: %lu\n\n", pCommand->pwszCmdToken, dwError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +346,7 @@ InterpretScript(
|
||||
ptr++;
|
||||
}
|
||||
|
||||
return InterpretCommand(args_vector, dwArgCount, &bDone) == FALSE;
|
||||
return InterpretCommand(args_vector, dwArgCount, &bDone);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ END
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_HELP_HEADER "\nThe following commands are available:\n"
|
||||
IDS_HELP_FOOTER "\nHelp Footer\n\n"
|
||||
IDS_HELP_FOOTER "\nTo view help for a command, type the command, followed by a space, and then\n type ?.\n\n"
|
||||
IDS_SUBCONTEXT_HEADER "\nThe following sub-contexts are available:\n"
|
||||
|
||||
IDS_HLP_UP "Goes up one context level.\n"
|
||||
@@ -35,6 +35,8 @@ BEGIN
|
||||
IDS_HLP_POPD_EX "Syntax: popd\n\n Changes to the context on the stack.\n\n"
|
||||
IDS_HLP_PUSHD "Stores the current context on the stack.\n"
|
||||
IDS_HLP_PUSHD_EX "Syntax: pushd\n\n Stores the current context on the stack.\n\n"
|
||||
IDS_HLP_EXEC "Runs a script file.\n"
|
||||
IDS_HLP_EXEC_EX "Syntax: exec <ScriptFile>\n\n Loads the script file and runs it.\n\n"
|
||||
|
||||
IDS_HLP_ADD_HELPER "Installs a helper DLL.\n"
|
||||
IDS_HLP_ADD_HELPER_EX "Syntax: add helper <dll file name>\n\n Installs the specified helper DLL in netsh.\n\n"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
BOOL
|
||||
DWORD
|
||||
RunScript(
|
||||
_In_ LPCWSTR filename)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ RunScript(
|
||||
if (script == NULL)
|
||||
{
|
||||
ConResPrintf(StdErr, IDS_OPEN_FAILED, filename);
|
||||
return FALSE;
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* Read and process the script */
|
||||
@@ -35,14 +35,14 @@ RunScript(
|
||||
if (InterpretScript(tmp_string) == FALSE)
|
||||
{
|
||||
fclose(script);
|
||||
return FALSE;
|
||||
return ERROR_SUCCESS; /* FIXME */
|
||||
}
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
fclose(script);
|
||||
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -220,4 +220,10 @@ InterpretCommand(
|
||||
VOID
|
||||
InterpretInteractive(VOID);
|
||||
|
||||
/* netsh.c */
|
||||
|
||||
DWORD
|
||||
RunScript(
|
||||
_In_ LPCWSTR filename);
|
||||
|
||||
#endif /* PRECOMP_H */
|
||||
|
||||
@@ -31,14 +31,16 @@
|
||||
#define IDS_HLP_POPD_EX 307
|
||||
#define IDS_HLP_PUSHD 308
|
||||
#define IDS_HLP_PUSHD_EX 309
|
||||
#define IDS_HLP_EXEC 310
|
||||
#define IDS_HLP_EXEC_EX 311
|
||||
|
||||
#define IDS_HLP_ADD_HELPER 310
|
||||
#define IDS_HLP_ADD_HELPER_EX 311
|
||||
#define IDS_HLP_DEL_HELPER 312
|
||||
#define IDS_HLP_DEL_HELPER_EX 313
|
||||
#define IDS_HLP_SHOW_HELPER 314
|
||||
#define IDS_HLP_SHOW_HELPER_EX 315
|
||||
#define IDS_HLP_ADD_HELPER 320
|
||||
#define IDS_HLP_ADD_HELPER_EX 321
|
||||
#define IDS_HLP_DEL_HELPER 322
|
||||
#define IDS_HLP_DEL_HELPER_EX 323
|
||||
#define IDS_HLP_SHOW_HELPER 324
|
||||
#define IDS_HLP_SHOW_HELPER_EX 325
|
||||
|
||||
#define IDS_HLP_GROUP_ADD 320
|
||||
#define IDS_HLP_GROUP_DELETE 321
|
||||
#define IDS_HLP_GROUP_SHOW 322
|
||||
#define IDS_HLP_GROUP_ADD 330
|
||||
#define IDS_HLP_GROUP_DELETE 331
|
||||
#define IDS_HLP_GROUP_SHOW 332
|
||||
|
||||
Reference in New Issue
Block a user