was hälst'n du davon:
Code:
@echo off
call \temp\read_passwd "bla x"
if errorlevel 1 goto passok
goto :eof
:passok
echo ok
http://rapidshare.com/files/284155187/read_passwd.exe
getestet unter xp-32 und win7-64.
für interessierte, das c(++)-programm:
Code:
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <string>
int _tmain(int argc, char* argv[])
{
using namespace std;
if (argc < 2) {
cout << "usage read_passwd <passwd>\n";
return 0;
}
string password;
char ch;
const char ENTER = 13;
const char BS = 8;
cout << "enter the password: ";
while((ch = _getch()) != ENTER)
{
if (ch == 3) { // ctrl-c
return 0;
}
if (ch == BS) {
if (password.length() > 0) {
password = password.substr (0, password.length() -1);
cout << BS << " " << BS;
}
continue;
}
password += ch;
cout << '*';
}
cout << "\n";
return strcmp (argv[1], password.data()) == 0;
}