Solved

Programmatically Unlocking a Windows200 PC

Posted on 2004-08-02
10
383 Views
Last Modified: 2012-06-21
How can I unlock a Win2K computer via script or Visual Basic?
I tried disabling Ctrl + Alt + Del at the group policy so when locking the PC it stays on the screen when you have to enter the password to unlock and then use Sendkeys but that does not work.
We reboot our servers on Saturday mornings and then have to start a program again on this PC. Starting the program with the script I wrote works great if the PC is not locked.
Please help.
Thanks.
0
Comment
Question by:MadridEspana
  • 4
  • 3
10 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 11698191
If the program doesn't use any user-specific features, e.g., HKCU hive, network connection, mapped drive letters, then you could use a service to start it at boot without having to wait for a user logon.

0
 
LVL 22

Expert Comment

by:cookre
ID: 11698256
0
 
LVL 3

Expert Comment

by:travisjhall
ID: 11699420
By "unlock a Win2K computer", do you mean "log on to a Win2K computer"? As in, after reboot, you hit Ctrl+Alt+Del to bring up the logon dialog, enter and username and password, and hit OK to start using the computer?

If so, there's no need to use script or VB to do this (and you may not be able to, anyway. I'm not sure it is possible, and it is certainly somewhat difficult even if it is possible.) Windows 2000 has a built-in feature to do this.

The feature you need is described in MSDN article Q253370. To summarise, you need to edit the registry. Find registry key HKEY_LOCAL_MACHINE\SOFTWARE\WindowsNT\CurrentVersion\WinLogon. Set the DefaultLogon, DefaultPassword and DefaultDomainName values to match whatever logon you wish to use, and set AutoAdminLogon (a REG_DWORD value, in case you need to create it) to 1. (The article doesn't mention DefaultDomainName, but if you are trying to log on using a domain account you will need to set this, I believe.) After doing this, the computer should attempt a logon automatically following a reboot - no programming necessary.

I would advise using Regedt32.exe to set appropriate security permissions on the WinLogon key, to make sure that nobody who shouldn't know it can read you admin logon password out of it.

Also, cookre is right, you can adopt various tactics to run your program as a service, but this isn't always an ideal approach (especially if said program is a third-party product that doesn't work well that way).
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 22

Expert Comment

by:cookre
ID: 11699601
That's a perfectly reasonable thing to do.  As a matter of fact, I do that on my home boxes (the lazy way with TweakUI).

In your environment, you may want to modify your code to do a logoff when the program is done, however, so you don't leave a logged on box unattended.
0
 
LVL 3

Expert Comment

by:travisjhall
ID: 11699771
There are some programs which need to be left running on a server sometimes. We have servers here where I work that are set to logon and run a program automatically and just keep running said program. These are third-party products which aren't suited to being run as a service. (I tend to write my own stuff such that it runs as a service if this is required.) However, our servers are kept in a locked server room. It's not an easy thing to do to physically access those servers, so we aren't terribly worried about the systems having a desktop.

Even if you can't prevent physical access to the machines, though, it is a simple matter to set the machine to automatically lock the desktop, without logging off.
0
 

Author Comment

by:MadridEspana
ID: 11710637
The server is continually running processes. Due to our ERP package MRP and other manufacturing programs can be scheduled to run at night but in order to run a user has to be logged on to the ERP package. You cannot run this as a process. On Saturdays we reboot our servers and in order to this process to be running I wrote a program that uses Sendkeys to log on and click on the Deferred Processing screen program. It works fine if the server is not locked. However the server is supposed to be locked when we are not there. I tried logoff instead of reboot and the logoff batch file works as long as the computer is not locked. It seems that nothing works when the computer is locked.
0
 
LVL 22

Accepted Solution

by:
cookre earned 500 total points
ID: 11711432
Unless I were willing to fiddle with the security model, I'd write a short executable (to run as a service) that calls CreateProcessAsUser() to start the app:

http://win32.mvps.org/security/lu_cpau.html
http://support.microsoft.com/default.aspx?scid=KB%3BEN-US%3BQ165194
0
 
LVL 3

Expert Comment

by:travisjhall
ID: 11711746
How are you locking the Server? Have you got something set up which locks it immediately upon logon, or is it a timed lock after a certain period of inactivity?

If it is acceptable for there to be a short delay between logging on and locking, can you just set your screen-saver settings to lock the computer after a certain period of inactivity? Then, you set up an automatic logon (as I described previously), activate the Deferred Processing screen program with a shortcut in the appropriate startup folder or an autorun setting in the registry, and you should have everything up and running before the computer locks the screen.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Export Table to CSV - Access to CSV - using python 18 133
creating threads in delphi 1 101
Tembedded WB animatid gifs not animated on some pcs 2 79
iSeries email authority 6 55
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This is an explanation of a simple data model to help parse a JSON feed
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now