mirror of
https://github.com/reactos/reactos.git
synced 2025-04-18 19:47:14 +00:00
[RUNAS] Add password input and improve help text
Now it works on windows xp and 10.
This commit is contained in:
parent
9ab5d3afb2
commit
c14440ee57
4 changed files with 106 additions and 22 deletions
|
@ -7,6 +7,17 @@ BEGIN
|
|||
IDS_USAGE03 " /user:<Benutzername> Programm\n\n"
|
||||
IDS_USAGE04 "RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]\n"
|
||||
IDS_USAGE05 " /smartcard [/user:<Benutzername>] Programm\n\n"
|
||||
IDS_USAGE06 "/noprofile"
|
||||
IDS_USAGE07 "/profile"
|
||||
IDS_USAGE06 " /noprofile Legt fest, dass das Benutzerprofil nicht geladen werden\n"
|
||||
IDS_USAGE07 " soll. Führt dazu, dass die Anwendung schneller geladen\n"
|
||||
IDS_USAGE08 " wird. Dies kann bei einigen Anwendungen zu Fehlern führen.\n"
|
||||
IDS_USAGE09 " /profile Legt fest, dass das Benutzerprofil geladen werden soll.\n"
|
||||
IDS_USAGE10 " Dies ist die Standardeinstellung.\n"
|
||||
IDS_USAGE11 " /env Verwendet die aktuelle Umgebung statt der des Benutzers.\n"
|
||||
IDS_USAGE12 " /user <Benutzername> muss in der Form Benutzer@Domäne oder\n Domäne\\Benutzer angegeben werden\n"
|
||||
IDS_USAGE13 " Programm Befehlszeile einer ausführbaren Datei. Siehe unten\n aufgeführte Beispiele.\n\n"
|
||||
|
||||
IDS_START "Es wird versucht, %s als Benutzer ""%s\\%s"" zu starten...\n"
|
||||
IDS_RUN_ERROR "RUNAS-FEHLER: %s kann nicht ausgeführt werden\n"
|
||||
|
||||
IDS_PASSWORD "Geben Sie das Kennwort für ""%s\\%s"" ein: "
|
||||
END
|
||||
|
|
|
@ -7,6 +7,17 @@ BEGIN
|
|||
IDS_USAGE03 " /user:<UserName> program\n\n"
|
||||
IDS_USAGE04 "RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]\n"
|
||||
IDS_USAGE05 " /smartcard [/user:<UserName>] program\n\n"
|
||||
IDS_USAGE06 "/noprofile"
|
||||
IDS_USAGE07 "/profile"
|
||||
IDS_USAGE06 " /noprofile specifies that the user's profile should not be loaded.\n"
|
||||
IDS_USAGE07 " This causes the application to load more quickly, but\n"
|
||||
IDS_USAGE08 " can cause some applications to malfunction.\n"
|
||||
IDS_USAGE09 " /profile specifies that the user's profile should be loaded.\n"
|
||||
IDS_USAGE10 " This is the default.\n"
|
||||
IDS_USAGE11 " /env to use current environment instead of user's.\n"
|
||||
IDS_USAGE12 " /user <UserName> should be in form USER@DOMAIN or DOMAIN\\USER\n"
|
||||
IDS_USAGE13 " program command line for EXE. See below for examples\n\n"
|
||||
|
||||
IDS_START "Attempting to start %s as user ""%s\\%s""...\n"
|
||||
IDS_RUN_ERROR "RUNAS ERROR: Unable to run %s\n"
|
||||
|
||||
IDS_PASSWORD "Enter the password for ""%s\\%s"": "
|
||||
END
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
#define IDS_USAGE01 7000
|
||||
#define IDS_USAGE02 7001
|
||||
#define IDS_USAGE03 7002
|
||||
#define IDS_USAGE04 7003
|
||||
#define IDS_USAGE05 7004
|
||||
#define IDS_USAGE06 7005
|
||||
#define IDS_USAGE07 7006
|
||||
#define IDS_USAGE01 7000
|
||||
#define IDS_USAGE02 7001
|
||||
#define IDS_USAGE03 7002
|
||||
#define IDS_USAGE04 7003
|
||||
#define IDS_USAGE05 7004
|
||||
#define IDS_USAGE06 7005
|
||||
#define IDS_USAGE07 7006
|
||||
#define IDS_USAGE08 7007
|
||||
#define IDS_USAGE09 7008
|
||||
#define IDS_USAGE10 7009
|
||||
#define IDS_USAGE11 7010
|
||||
#define IDS_USAGE12 7011
|
||||
#define IDS_USAGE13 7012
|
||||
#define IDS_USAGE_MAX IDS_USAGE13
|
||||
|
||||
#define IDS_START 7100
|
||||
#define IDS_RUN_ERROR 7101
|
||||
#define IDS_PASSWORD 7500
|
||||
|
|
|
@ -23,17 +23,52 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define MAX_PASSWORD_LENGTH 64
|
||||
|
||||
static
|
||||
void
|
||||
Usage(void)
|
||||
VOID
|
||||
Usage(VOID)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_USAGE01);
|
||||
ConResPuts(StdOut, IDS_USAGE02);
|
||||
ConResPuts(StdOut, IDS_USAGE03);
|
||||
ConResPuts(StdOut, IDS_USAGE04);
|
||||
ConResPuts(StdOut, IDS_USAGE05);
|
||||
ConResPuts(StdOut, IDS_USAGE06);
|
||||
ConResPuts(StdOut, IDS_USAGE07);
|
||||
int i;
|
||||
for (i = IDS_USAGE01; i <= IDS_USAGE_MAX; i++)
|
||||
ConResPuts(StdOut, i);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
ConInString(
|
||||
_In_ PWSTR pInput,
|
||||
_In_ DWORD dwLength)
|
||||
{
|
||||
DWORD dwOldMode;
|
||||
DWORD dwRead = 0;
|
||||
HANDLE hFile;
|
||||
PWSTR p;
|
||||
PCHAR pBuf;
|
||||
|
||||
pBuf = (PCHAR)HeapAlloc(GetProcessHeap(), 0, dwLength - 1);
|
||||
ZeroMemory(pInput, dwLength * sizeof(WCHAR));
|
||||
hFile = GetStdHandle(STD_INPUT_HANDLE);
|
||||
GetConsoleMode(hFile, &dwOldMode);
|
||||
|
||||
SetConsoleMode(hFile, ENABLE_LINE_INPUT /*| ENABLE_ECHO_INPUT*/);
|
||||
|
||||
ReadFile(hFile, (PVOID)pBuf, dwLength - 1, &dwRead, NULL);
|
||||
|
||||
MultiByteToWideChar(GetConsoleCP(), 0, pBuf, dwRead, pInput, dwLength - 1);
|
||||
HeapFree(GetProcessHeap(), 0, pBuf);
|
||||
|
||||
for (p = pInput; *p; p++)
|
||||
{
|
||||
if (*p == L'\x0d')
|
||||
{
|
||||
*p = UNICODE_NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetConsoleMode(hFile, dwOldMode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,7 +204,22 @@ wmain(
|
|||
DPRINT("Domain: %S\n", pszDomain);
|
||||
DPRINT("CommandLine: %S\n", pszCommandLine);
|
||||
|
||||
/* FIXME: Query the password: */
|
||||
if (pszDomain == NULL)
|
||||
{
|
||||
DWORD dwLength = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
pszDomain = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
|
||||
if (pszDomain)
|
||||
GetComputerNameW(pszDomain, &dwLength);
|
||||
}
|
||||
|
||||
pszPassword = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (MAX_PASSWORD_LENGTH + 1) * sizeof(WCHAR));
|
||||
|
||||
/* Query the password */
|
||||
ConResPrintf(StdOut, IDS_PASSWORD, pszDomain, pszUserName);
|
||||
ConInString(pszPassword, MAX_PASSWORD_LENGTH + 1);
|
||||
ConPuts(StdOut, L"\n");
|
||||
|
||||
ConResPrintf(StdOut, IDS_START, pszCommandLine, pszDomain, pszUserName);
|
||||
|
||||
rc = CreateProcessWithLogonW(pszUserName,
|
||||
pszDomain,
|
||||
|
@ -184,7 +234,8 @@ wmain(
|
|||
&ProcessInfo);
|
||||
if (rc == FALSE)
|
||||
{
|
||||
DPRINT("Error: %lu\n", GetLastError());
|
||||
ConResPrintf(StdOut, IDS_RUN_ERROR, pszCommandLine);
|
||||
ConPrintf(StdOut, L"Error: %lu\n", GetLastError());
|
||||
}
|
||||
|
||||
done:
|
||||
|
|
Loading…
Reference in a new issue