Writing Terminal Service BasedScripts
Being a child of the 1980s, I pretty much grew up with DOS. As such, I became very comfortablewith DOS commands, and still work extensively with the Windows Command Prompt to this day.Many administrators simply assume that the Windows Command Prompt is a relic that’s left over from the 1980s. In fact, I’ve got a good friend in Kentucky who has been making fun of me for wellover a decade for my various Command Prompt exploits (yes, I’m talking to you Shamir).There is a lot more to the Command Prompt than meets the eye. As Windows has evolved, so toohas the Command Prompt. Sure, most of the original DOS commands are still supported, butMicrosoft has added countless new commands over the years. Many of these commands arenetworking related, and some are specifically related to the Windows Terminal Services.In this article series, I am going to introduce you to some of the commands that are the most usefulto terminal service administrators. Some of the commands that I will be discussing are not directlyrelated to the terminal services, but are still very useful in a terminal service environment. Other commands are specifically related to the terminal services. My plan is to spend the next severalarticles in this series introducing you to some various commands, and demonstrating how thosecommands work. Later in the series, I will show you how to use the various commands to createautomated scripts.
The Change Logon Command
The Change Logon command allows you to enable or disable session logins from the CommandPrompt or from an automated script. One way that I have seen this command used in the real worldinvolved a company which needed to lock the users out of a particular server for a few hours eachnight so that various maintenance tasks could be performed. The administrator of that particular company developed a script that disabled session logons, ran the maintenance tasks, and then re-enabled logons.The syntax for this command is very simple. Simply enter the CHANGE LOGON command,followed by one of three switches:
•
/QUERY
Tells you whether session logons are currently enabled or disabled
•
/ENABLE
Enables session logons
•
/DISABLE
Disables session logonsIf you look at Figure A, you can see the Change Logon command in action. In the figure, I haveentered the CHANGE LOGON /? command so that you can see the command syntax, and then Ihave entered the CHANGE LOGON /QUERY command, so that you can see the query’s output.
Leave a Comment