Version 1.2

Table of Contents

Overview

Command Summary

Using NTconnect in a NT Login Script

Script Options

Technical Support

Registration


Overview

NTconnect Overview

NTconnect's primary purpose is to provide many of the same capabilities of a Novell Netware login script under NT.  As a secondary objective, NTconnect also provides some unique command-line support in areas that currently do not have command-line options under Windows NT.

NTconnect currently supports the following commands, either directly from the command-line or via a script file:

connection to network drives (shared resources)

connection to network printers

removing network drive connections

removing printer connections

registry entry modifications

program execution

conditional command execution based on user/group membership

All commands can be put into a "script" file, and can be executed for all users, specific users, or by specified user group.  NTconnect can be run from the command line, from Program Manager, or via the "Login Script" option setting available in User Manager under Windows NT.

Since Windows NT does not have a very extensive command-line language, NTconnect incorporates it's own batch "language".  NTconnect can be used to directly execute a single command from a command line parameter, using the syntax:

NTconnect command

"command" can be any valid command as documented in the Command Summary.

To execute a series of commands from within a script file, execute NTconnect using the following syntax:

NTconnect script scriptfilename

You may provide a path to your script file, if desired.

Any text editor can be used to create NTconnect script files, and any desired formatting (blank lines, spaces, or tabs) within the script file.  NTconnect is NOT case-sensitive, so any combination of upper/lower case letters can be used.  However, passwords (if entered in a script or on the command line) must be entered in the correct upper/lower case.

Command qualifiers are preceded by the "/" character.  Qualifiers can be entered in any order for a command, however, one or more spaces must separate each qualifier.

For a list of the commands currently supported by NTconnect, see the Command Summary.  For steps on incorporating NTconnect into a login script, see Using NTconnect in a NT Login Script.


Using NTconnect in a NT Login Script

To use NTconnect as a NT login script processor, users must be configured using NT's User Manager for Domains.  You must be a NT domain administrator to use this utility.  Follow the steps outlined below to configure a NTconnect login script:

1.  Using User Manager for Domains, select the user(s) requiring a login script, and then choose Properties from the User menu.

2.  From the User Properties dialog box, choose the Profile button.

3.  The User Environment Profile dialog box will appear (see illustration above).  In the Logon Script Name field, enter a name of a NT batch file, for example "Login.BAT".  The contents of this file are explained below.  Click OK to close the User Environment Profile dialog.  Click OK to close the User Properties dialog.

4.  Create the login batch file (named "Login.BAT" in the above example) using a text editor such as Notepad.  At minimum, place a command to run NTconnect with a script file in this batch file.  For example, to run a script file named "Login.scr", place this command in your NT login script file:

NTconnect script Login.scr

5.  Save both the NT login script file (Login.BAT) and the NTconnect script file (Login.scr) in your primary domain controller's NetLogin directory, usually located in \<winnt_root>\system32\repl\import\scripts.  This directory is shared using the share name "netlogin".  Also make sure that a copy of the NTconnect.exe program is also in this directory.

It is advisable to use (as in the above example), a batch file for a login script, and then run NTconnect from this batch file rather than using NTconnect directly as a login script.  Using a batch file gives greater flexibility and control, since additional NT commands can be placed in the batch file as appropriate.  NT also allows passing parameters to a login script batch file.  This allows setting up a login script batch file to conditionally (based on the parameter(s) passed to it) execute commands in the login process.  Note that Service Pack #3 must be loaded in order for login script batch files to accept parameters.

Note:  Make sure that all batch, script, and NTconnect.exe files get replicated (copied) to all backup domain controllers (BDCs) in your domain.


NTconnect Command Summary

Usage:  NTconnect [Command Line]

Command Line / Script Commands Summary

NTconnect currently supports the following commands.  Unless indicated otherwise, these commands can be used in either script files or from the command line.  All command qualifiers are optional.

Script scriptfilename

ConnectPrinter \\server\printername [/default]

ConnectDrive drive: \\server\sharename [/persistent] [/user:] [username] [* | password] [/home]

RemovePrinter \\server\printername [/confirm] [/noerror]

RemoveDrive [drive: | *] [/confirm] [/persistent] [/force] [/noerror]

Registry registry hive\registrypath\registry key:[integer value | "string value"]

Note: The Registry command cannot be used as a command line argument

Run program name

Message message text

Echo message text

Beep

Rem [remarks]

Note: A ";" can also be used to start a comment line.

Exit

Environment Variables

%username%

%userdomain%

%homepath%

%homeshare%

%homedrive%

%computername%

User / Group / Computer Options

[USER:username]

[GROUP:group name]

[COMPUTER:computer name]

Script File Options

Error_Popup:[YES | NO]

Max_Connection_Attempts:[value]


Connecting To Network Printers

Usage: ConnectPrinter \\server\printer name [/default]

Connections can be made to network printers using the "ConnectPrinter" command and supplying the full printer UNC name in the command path.  Printers connected in this manner will be made immediately available to Windows NT programs; the printers will also be immediately assessable by Print Manager.  Examples of the ConnectPrinter command are as follows:

ConnectPrinter \\Server1\HP LaserJet

ConnectPrinter \\Marketing\HP 4si /default

It is advisable to use the printer name (not the share name) when connecting to network printers.  Generally, the printer name is more descriptive, and will prevent problems when using the /default command qualifier (see below).

To make a printer connection the default printer, use the /default qualifier.  The /default command is only supported if the printer name (not the share name) is used.


Connecting to Network Drives

Usage: ConnectDrive	drive: \\server\sharename [/persistent] [/user:] [username] [* | password]

drive: /home

Connections can be made to network drives in a manner similar to NT's "NET USE" command. However, there are some command and behavior differences.  One major difference between the NET USE command and NTconnect is how the username and password are supplied when user input is required.  The NET USE command uses a DOS-like command environment for entry of user information.  NTconnect, however, uses a standard Windows dialog box for all user entry, thereby providing a more familiar and user-friendly interface.  NTconnect also gives detailed error messages and can reprompt for password information automatically.

To connect to network drives, use the "ConnectDrive" command. The following examples show the supported methods for connecting to network drives.

ConnectDrive M: \\Server1\Marketing

This command example would connect drive "M:" to the "Marketing" share on server "Server1".  NTconnect would use the current NT username and password in attempting to make the connection.  If the connection fails due to an invalid username/password, NTconnect will prompt for another username and password.

ConnectDrive M: \\Server1\Marketing /USER:

This command variation would prompt for both username and password prior to making the connection.

ConnectDrive M: \\Server1\Marketing /USER:JOHNSMITH

This command variation would default the username to "JohnSmith", but use the current NT password in attempting to make the connection.

ConnectDrive M: \\Server1\Marketing /USER:JOHNSMITH *

This command variation would default the username to "JohnSmith", and would prompt for the password.

ConnectDrive M: \\Server1\Marketing /USER:JOHNSMITH yesterday

This command variation would make the connection to drive M: using the username "JohnSmith" and the password "yesterday".

Use the /PERSISTENT command qualifier to make NT automatically remember the drive connection the next time you log on. For example:

ConnectDrive M: \\Server1\Marketing /PERSISTENT

The above command would connect drive "M:" to the Marketing share on server "Server1".  The next time you log on, NT would automatically restore the connection.

The ConnectDrive also supports the /HOME qualifier, which enables creating a drive connection directly to the user's home directory.  The following command example would connect drive "M:" to the user's home directory:

ConnectDrive M: /HOME

By default, if an invalid username or password is entered during processing of a ConnectDrive command, NTconnect will automatically reprompt for a valid username and password.  If the username/password supplied is still invalid, script processing will continue without reprompting the user for another username and password.  The number of login attempts, however, can be controlled by use of the Max_Connection_Attempts option statement.  For more information on this script option, see the Script Options section.


Registry Commands

Usage: Registry HKEY_xxx\RegistryPath\RegistryKey:[value | "value"]

NTconnect can be used to modify the Windows registry by using the Registry command in a script file.  The first part of the Registry command consists of the name of the registry hive, which must have one of the following four (4) values:

HKEY_CLASSES_ROOT

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_USERS

The next part of the Registry command is the registry path, which includes all subtree paths required for the registry key.  The final part of the Registry command includes the actual name of the registry key followed by the key value.  For example, the following command will reverse the left and right mouse buttons for a Windows NT 3.51 user:

Registry HKEY_CURRENT_USER\Software\Control Panel\Mouse\SwapButtons:1

NTconnect currently supports two kinds of registry values: String (REG_SZ) and Double Word (REG_DWORD).  To create a string (REG_SZ) registry entry, surround the key value with quotation marks.  For example:

Registry HKEY_CURRENT_USER\Software\Test\TestString:"This is a test"

This example places the string value "This is a test" into the "TestString" key in the Software\Test path in the registry hive "HKEY_CURRENT_USER".

To create a Double Word (REG_DWORD) registry entry, enter the numeric value without the quotation marks.  Only valid numeric entries that can be converted into a DWORD value will be stored.

NOTE:  Registry commands cannot be executed from the command line; they MUST be included inside of script files in order to execute properly.


Running a Script

Usage: Script ScriptFileName

The Script command can be used from the command line to have NTconnect run a script file, or it can be placed in a script file to run another script file.  For example, the following command would execute the "Login.scr" script file located in the "script" share on the "Server1" server:

NTconnect script \\Server1\script\Login.scr

A file extension should be always be used on the script file name; NTconnect does NOT assume a default script file extension.  If a UNC path is not provided to the script file, NTconnect will look for the script file in the current working directory.  If NTconnect is being used during the NT login process, then the default working directory will usually be the user's home directory.  If the script file cannot be found in the current working directory, NTconnect will look in the primary domain controller's (PDC) netlogin share directory.

For information on how to use NTconnect in a NT login script, see Using NTconnect in a NT Login Script


Using Environment Variables

Usage: %EnvironmentVariable%

Environment variables are special "codes" that can be placed in script commands that are dynamically replaced with specific NT environment settings when the script is executed.  Environment variables are always preceded and followed with a "%" character.  Supported variables include:

%USERNAME%	Contains the current username

%USERDOMAIN%	Contains the domain name from which the script is executing.

%HOMEDRIVE%	Contains the drive letter for the user's home directory

%HOMEPATH%	Contains the path to the user's home directory (if any)

%HOMESHARE%	Contains the share name of the user's home directory (if any)

%COMPUTERNAME%	Contains the name of the workstation/server

Examples:

Echo Hello %USERNAME%, you are logging into the %USERDOMAIN% domain

If a user named "JohnDoe" from domain "Primary" were executing the above example, the phrase displayed on the NT login script command window would be:

"Hello JohnDoe, you are logging into the Primary domain"

ConnectDrive W: \\Server1\%USERNAME%

For a user named "JohnDoe", the above example would connect drive "W:" to the "JohnDoe" share on server "Server1".


User, Group, and Computer Options

Usage: 	[USER:username]

[GROUP:groupname]

[COMPUTER:computername]

One of the most powerful features of NTconnect is its capability to selectively control which commands in a script file get executed depending upon an individual user,  a user's membership in selected groups, or a specific computer.

To specify commands for a specific user, put a bracketed "section" in the script file with the keyword USER: followed by the name of the user.  For example, to create a section for a user named "JohnSmith", use:

[USER:JohnSmith]

All script commands after this section will be executed for user "JohnSmith", until the next section is encountered.  To specify commands for a group, put a bracketed section in the script file with the keyword GROUP: followed by the group name.  Remember to include any punctuation, including spaces in the group name, if necessary.  For example, to create a section for the "Domain Admins" group, use:

[GROUP:Domain Admins]

Finally, to specify a section of commands that are to be executed only on certain computers, create a section using the COMPUTER keyword as follows:

[COMPUTER:MARKET1]

User, Group, and Computer sections can be placed in any order in the script file.  However, it is recommended to place user and group sections together to better organize the script file contents.  For information on how to use NTconnect in a NT login script, see Using NTconnect in a NT Login Script


Other Commands

Usage: Exit

Use the "Exit" command from within a script section to immediately stop all script execution.  Generally, this command is used when it is known that a given section contains the last commands for a given group or user.

Tip:  If individual user sections are included in the script file, place the user sections after the group sections, and place an Exit command at the end of each user section.  This will prevent NTconnect from having to read the entire script file for each user logon.


Running Other Programs

Usage: Run programname

To run another program, including batch (.BAT) files, use the "Run" command, followed by the path and name of the program or batch file.  Programs run in this manner will be started during execution of the script, but will not interfere with execution of additional script commands.

Sending Messages

Usage:	Message messagetext

Echo messagetext

Beep

Use either the "Message" or "Echo" commands to display messages during script execution.  Use the "Message" command to display a "message box" to the user; the message box will require the user to click the OK button (or press Enter) to clear the message.  While the message is displayed, script execution will be halted.

Use the "Echo" command to display messages to NT's login command window.  These messages will be visible to the user only during execution of the script.

The "Beep" command can be used to issue a beep.  The sound used will correspond to the sound that is associated with the exclamation event on the user's PC.


Removing Network Printer Connections

Usage: RemovePrinter \\server\printer name [/confirm] [/persistent] [/noerror]

To remove a printer connection, use the "RemovePrinter" command, followed by the full UNC path to the printer.  For example, the following command example would remove a connection to a printer named "HP 4si" on the server named "Marketing":

RemovePrinter \\Marketing\HP 4si

To remove all printer connections, use an "*" in place of the printer name.  For example:

RemovePrinter *

The remove printer command supports the following command qualifiers:

/confirm  prompts the user for confirmation before removing the printer connection.

/noerror  suppresses any error messages.  Use this qualifier if, for example, you do not want an error message to be displayed if the printer is not connected.

NOTE: Removing printer connections does not remove the actual printer from the server.  It only affects the current user's desktop configuration.

See Also: Connecting To Printers


Removing Network Drive Connections

Usage:	RemoveDrive [drive: | *] [/confirm] [/persistent] [/force] [/noerror]

To remove a network drive connection, use the "RemoveDrive" command, followed by the drive letter to remove, such as in the following example:

RemoveDrive M:

The above example would remove the network connection to drive "M:".

To delete all network drive connections, use an "*" in place of the drive letter, such as in the following example:

RemoveDrive *

The RemoveDrive command supports a number of optional command qualifiers as follows:

/confirm  requires user verification prior to removing the drive connection.

/force  force the drive to be disconnected, even if files are currently open.  If the /force qualifier is not used, NTconnect will display an error message, and will prompt if the drive should be forcably disconnected.

/persistent  removes the drive connection from your profile. Windows  NT will not restore this connection during subsequent logons.  If the /persistent qualifier is not used, the drive connection will be restored during the next logon.

/noerror  suppresses any errors, regardless of the type of error. This qualifier is useful in cases where the success or failure of the RemoveDrive command is not important.

NOTE: Using any of the command qualifiers with a wildcard drive removal command (*), will result in the same qualifier(s) being applied to all drive connections.


Script Options

NTconnect script file options are used to control script processing behavior.  An option will only take effect until it is encountered by NTconnect in the course of processing the script, and will remain in effect until another option command is issued.  Option commands are generally placed at the beginning of the script, but can also be placed anywhere in the script file.  All option commands have the following format:

Option [option_command]:[option_value]

Valid option commands, their associated values, and the defaults used by NTconnect are as follows:

Error_Popup:[YES | NO]

Default: YES

Use the Error_Popup option to enable or disable popup message boxes when errors are encountered by NTconnect.  By default, NTconnect will display a popup error message when any error is encountered.  Script processing will be halted when a popup error message is displayed.  To direct error messages to the output window (ie the screen) without stopping script processing, set Error_Popup to "NO".  Error_Popup has no effect on the Message command: Messages will still use a popup window.

Note:  While setting Error_Popup to "NO" will force script processing to continue even when errors are encountered, error messages will be visible to the user only for the brief time that NT's login script "command window" is displayed.

Max_Connection_Attempts:[Value]

Default: 2

The Max_Connection_Attempts option allows setting the maximum number of times NTconnect will allow a user to attempt to make a drive connection.  Unless specified otherwise, NTconnect will reprompt a user one time for a valid username and password (in effect, attempting to connect two (2) times).  Once the maximum connection attempts has been tried, NTconnect will abort the drive connection attempt and continue processing other script commands.

Setting a value of one (1) for Max_Connection_Attempts will force NTconnect to only try to make a connection one time; the user will not be prompted or reprompted for a valid username/password.

Note:  Avoid setting Max_Connection_Attempts at too high of a value, as it may cause the NT user account to become locked out, due to NT's built-in security lockout features.


Registration

To register your use of NTconnect, send an email message to kstanush@aol.com containing the following information:

Your Name

Company Name and Address

Telephone Number(s)

EMail address

Number of servers and workstations utilizing NTconnect

This information will be used strictly to inform you/your company of NTconnect updates and future related software components; your name will not be given to other sources  You will be notified (by email) of any future updates of NTconnect and where/how to obtain them.  Early registration also allows for future discount options, should a registration fee be imposed in the future.

NTconnect can be freely distributed to others, as long as no income is derived from its distribution or sale.  All distributions of NTconnect must include any and all support files, including documentation, without modification.  NTconnect remains the property of Adkins Resource and its owner, Kevin Stanush, by whom no liability or obligation is assumed or taken for the use of this product.


Technical Support

Technical support for NTconnect can be obtained by contacting Adkins Resource at kstanush@aol.com, or by mail at:

Adkins Resource

P.O. Box 1077

Adkins, TX 78101

Please include a very detailed description of the problem, and if applicable, send a copy of the login script.  Also, please include the NT version(s) in use for the server(s) and the type of operating system(s) used for the client workstations.