Auto-login, auto-lock?

I have a couple of our WindowsNT application servers set to auto-login, but I would like to have them locked immediately when they reboot instead of waiting for the screen saver to lock the console.  Is that possible?
LVL 35
Mark GeerlingsDatabase AdministratorAsked:
Who is Participating?
LongbowConnect With a Mentor Commented:
Resource Kit Tool.
A doc file is included if i remember well.

The AutoExNT Service allows you to start a custom batch file, Autoexnt.bat, when you start a computer - without having to log onto the computer on which it will run.

AutoExNT includes an /interactive option (analogous to the /interactive option of the AT command) that allows you to see the processes started. To use AutoExNT, you must be running Microsoft? Windows? 2000, Microsoft? Windows NT? version 4.0, or Microsoft? Windows NT? 3.5 or later.

As no user-environment variables have yet been declared when AutoExNT runs at system startup, you must use full path names. If you need a service to be running, such as the Server or Schedule service, include a net start service command at the beginning of your Autoexnt.bat file before you start running a dependent process.

It's confusing.  If you want to lock your computer after reboot why don't you remove auto-login feature. what different if you use auto-login and then lock it right away?  You still need to retype your password.
Mark GeerlingsDatabase AdministratorAuthor Commented:
I need the server to auto-login to be able to run some applications that cannot run as services, but need to be running if/when the server is ever rebooted.  I'm not at work around the clock, but if there is ever a power supply problem during the night or on a weekend, I need those applications running as soon as the server restarts, whether I am there or not.  I would just like to know though that if others are in the room when it reboots, they don't get easy access to the console.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

make a shortcut in the startup folder on your system with the following target.

rundll32 user32.dll,LockWorkStation

this will lock your screen on startup.


damn ... sorry, that is for win2K only ....
for NT you need to do the following :
Windows NT 4.0
There is no solution to lock a Windows NT 4.0-based workstation from the command line. You can, however, achieve a similar effect with some additional configuration.

In Windows NT 4.0, you can use the SendMessage call to send a SC_SCREENSAVE message to the topmost window, which locks the workstation if the current user has a screen saver configured and the screen saver is configured to require a password.

To ensure that a screen saver is configured, you can create registry entries. Run a registry (.reg) file that adds the following entries from the command line:
HKCU\Control Panel\Desktop\ScreenSaveActive = 1
HKCU\Control Panel\Desktop\ScreenSaverIsSecure = 1
HKCU\Control Panel\Desktop\ScreenSaveTimeout = timeout in seconds
HKCU\Control Panel\Desktop\SCRNSAVE.EXE = %SystemRoot%\System32\Appropriate screen saver.scr
Some screen savers require additional parameters in HKCU\Control Panel\Screen Saver.screen saver name as well.

After you create these registry entries, the following call invokes the screen saver:
You must write and compile a short program (.exe file) that contains this call. You can then call your program from the command line to activate the screen saver. Because the ScreenSaverIsSecure value in the registry has been set to 1, this has the effect of locking the workstation.
Mark GeerlingsDatabase AdministratorAuthor Commented:
Thanks for the responses, forenzixbe.

I had tried the rundll32 approach and got an error, "missing entry: LockWorkStation".  I will keep that tip though for when we move to Windows2000 - maybe later this year.

I don't have a C compiler (or any other way to make an *.exe file), but I do know someone who does, so if there is no other way I may ask him to help me.

I'll reject your answer for now, but if no one has anything better, I'll accept it later.
Mark GeerlingsDatabase AdministratorAuthor Commented:
Thank you, Longbow - that looks like the solution I was hoping for.  I've had a couple other problems I've had to deal with first.  I hope to try Autoexnt later today.
Mark GeerlingsDatabase AdministratorAuthor Commented:
That works great!  Thank you.
I know this post is old, but I needed the same solution, and I found one. If you use PCAnywhere, set it up to autostart, and lock the workstation on startup, and on any kind of disconnection under the settings tab. I tried it using sysinternals autologon from a restart and a full power cycle.
All Courses

From novice to tech pro — start learning today.