Ever wish you had an easy way to perform a Login and Logout operation on a Windows Managed Device over a period of time without manual intervention? Check out this great solution from Novell engineers Lingam Rajesh and Vijay Kumar Kunchakuri.

While working with ZENworks Configuration Management (ZCM) policies for Windows in a test setup or customer lab environment, you may wish to perform a repetitive login and logout operation in order to test the reliability of your User and Device-based policies, such as a Dynamic Local User (DLU) Policy.

This Cool Solution will help you in performing a repetitive login and logout on the managed device over a specified period of time without any manual intervention. The solution basically utilizes the RDP tool available with a Windows Operating System.

Create RDP Configuration file:

Launch the Remote Desktop Connection on a Windows device.

Input the Computer, Username, Password, Domain and select the Save my Password option.
The Username and Password here should be the same as the eDirectory credentials if you are
testing a DLU Policy.

Click "Save As..." and save the above settings into a .rdp configuration file.

Note: You can manually edit the configuration file (except for the password which will be in an encrypted form).
Hence when the password changes, you need to recreate this .rdp configuration file.

Launch RDP Console Session:

To launch an RDP Console Session from the DOS Command Line, use the following Command:

Also, since this would be Session 0 on the device, ensure that there are no Users logged onto the physical device.

Automatic Logout from RDP Console Session:

Create a .bat (batch) file on the Windows Managed Device where the ZCM Adaptive Agent is installed.

To perform certain operations in the above console session and then to logout from the device automatically,
edit the content of the batch file to be something like the following and save it on the device.

Add this batch file to the Windows Registry as a new String Value, so that the above tasks get executed as soon as
the User logs in to the device.

The path to the Windows Registry is, HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

Automate the whole process:

A perl script or a batch file should be created to do the above operations, viz., launching RDP console session to the device, performing certain user required operations on the device and then automatically logging out from the device repeatedly, at regular intervals of time.

The perl script which we have come up with is:

###################################Perl Script to Automate Windows Login And Logout#################################
#!C:\perl\bin\perl
## Name : Rajesh Lingam
## Title : Auto login and logout on a Windows Device
$c=100; # Number of times user wants to login and logout of the Windows Device
$i=1;
print "No of times the login and logout process passed: \n";
while($c)
{
`mstsc \console C:\Documents and Settings\lrajesh\My Documents\RDP_Configuration\lrajesh.rdp`;
print $i;
print "\n";
$c--; # Decrimenting the count by one
$i++;
sleep 900; # Time duration in seconds, between each logout and the next login to the device.
wait;
}
################################################################################################################