[Editor's Note: Share your Windows 2000 and Windows NT discoveries, comments, problems, solutions, and experiences with products and reach out to other Windows 2000 Magazine readers (including Microsoft). Email your contributions (400 words or less) to r2r@win2000mag.com. Please include your phone number. We edit submissions for style, grammar, and length. If we print your submission, you'll get $100.]
Recover Administrator Passwords
I've seen many methods for recovering a forgotten administrator password on a Windows NT machine. However, most of the solutions are potentially destructive or unnecessarily complex. I've used the following easy-to-use solution on NT 4.0 machines, but I think it works on all NT versions.
First, shut down and reboot the machine so that you can gain access to the system's installation directory. You can use a DOS disk to access a FAT partition's installation directory and NTFSDOS to access an NTFS partition's installation directory. After you access the installation directory, rename logon.scr as logon.scr.back, then copy command.com to logon.scr. After you reboot the machine and wait about 15 minutes, the system will present you with a DOS prompt. At this point, you have full administrator access. Through the command prompt or User Manager, add a new administrator or change the administrator password, rename logon.scr.back to logon.scr, and close the DOS window.
Brian Laing
blaing@iss.net
Generate a Filename from the Current Date
To generate a filename derived from the current date, you can enable command extensions and use the For command and /f switch to parse the current date, which you use the date /t command to obtain. For example, the following command parses the current date into four tokens, which it delimits with a slash (/), hyphen (-), or a space:
for /f "tokens=1-4 delims=/- "
%%i in ('date /t') do
work.bat %%j-%%k-%%l
The first token is %%i, the second token is %%j, the third token is %%k, and the fourth token is %%l.
The format of the string that date /t returns is always numeric. However, the order of the day, month, and year, as well as the delimiter, depends on how you set the Short date style on the Date tab of the Control Panel Regional Settings applet. On my machines, the date /t command returns the date in the form Tue 14-09-1999 or Tue 14/09/1999. Thus, I need to specify three possible delimiters.
In the previous script, you can use any command following the do keyword. In my example, I call another batch file and pass to that batch file the current date that I rebuilt using hyphens as separators. You can use a date in the following format to rename an existing file:
for /f "tokens=1-4 delims=/- "
%%i in ('date /t') do rename
output.txt %%j-%%k-%%l.txt
Alternatively, you can use the date as a filename and pipe output directly to the new file, as follows:
for /f "tokens=1-4 delims=/- "
%%i in ('date /t') do echo
Hello >%%j-%%k-%%l.txt
Ahlan Marriott
ahlan@marriott.org
When I tried the technique, it didn't work. However, I tried copying cmd.exe to logon.scr, and that worked. About 15 minutes after I rebooted, the cmd.exe window appeared, and I was able to change the administrator's password. I exited cmd.exe and proceeded to log on as the administrator with the new password.<br><br>
Nicholas Pantelopoulos December 01, 2000