**********************************
*   "PUSH" script system v2.0    *
**********************************
*   By: Vernon Graner, SSE and   * 
*       Brian Hill, SSE          *
* (support@softwaremetering.com) *
*                                *
**********************************
*  Last Updated:  July 19, 2004  *
**********************************

*************
* OVERVIEW: *
*************

SofTrack uses the LWA (Local Workstation Agent) to gather information and enforce licensing on workstations that have locally loaded applications. The LWA components need to be copied to the local hard drive of each workstation, and if you do not have a "deployment" system for your network, this can be cumbersome. Though it is possible to use the "example login batch file" to allow your users to receive the LWA components when they login to a server, but this can be problematic if:

a) the user "cancels" the batch file before it completes,
b) the user does not have sufficient rights to create a service on their local workstation, or
c) the user does not have the right to copy files into the SYSTEM32\DRIVERS folder of their workstation (the login script runs with the same permissions levels as the user logging in). 

To overcome the login script limitations, and to allow an administrator to control when an LWA is deployed (the login scripts must wait for the user to initiate a login before it can run), the "PUSH" scripting system was developed.

The "PUSH" scripting system is distributed in two different versions, AT and PSEXEC. Both of the versions are identical, with the only exception being how the LWASETUP.BAT is executed on the target workstation. The two different versions of the "PUSH" system are defined in greater detail below.

*********************
* BEFORE YOU BEGIN: *
*********************

In order to have this system work successfully, you must meet the following criteria:

1) Familiarization with DOS batch files.
2) Familiarization with NTFS file permissions.
3) Must have "Administrative" access to all machines. This script assumes you have these rights!
4) The target workstation(s) MUST have a "hidden" C$ share that is remotely accessible. This can be tested by performing the following steps:

 a) Opening a command prompt (CMD), and typing "NET USE * \\WORKSTATION_NAME\C$" (without quotations), and pressing ENTER.
 b) If the drive mapping is successful, you should be able to see the target workstation's "C" drive via Windows Explorer.
 c) You can remove the drive mapping by typing "NET USE \\WORKSTATION_NAME\C$ /DEL" (without quotations), and pressing ENTER at the command prompt.

5) The target workstation(s) MUST be Windows NT/2000/XP or above. This WILL NOT work for Windows 9x/Me workstations!


****************************
* SCRIPT VERSIONS DEFINED: *
****************************

+ AT (Windows Automated Task Scheduler):

This version of the "PUSH" scripting system adapts the use of the Windows Task Scheduler service, which is part of the Microsoft Windows NT/2000/XP operating system. The script works by:

a) processing the list of target workstations defined in the LOOP.BAT file, 
b) mapping a network drive to the hidden "C$" share of each target workstation,
c) creating a LWASETUP directory on the target workstation,
d) copying the necessary LWA files from the STAGING directory on the administrator's workstation to the to the LWASETUP directory on the target workstation, and
e) scheduling an automated task on the target workstation to execute the LWASETUP.BAT file at the predetermined time. 

As a result, the SofTrack Local Workstation Agent is installed on each target workstation at the time you specify.

+ PSEXEC (PS Exec executable developed by Sysinternals, Inc.):

This version of the "PUSH" system adapts the use of Sysinternals' PSEXEC.EXE freeware tool. PSEXEC allows an individual with administrative rights to remotely execute a program (batch file) on the target workstation. This version of the "PUSH" system was developed solely as an alternative for those environments that have Windows Task Scheduler disabled on the target workstations, either through the use of Group Policy, or some other means. 

This script works by performing steps A through D mentioned above, however, the last step executes the LWASETUP.BAT file on the target workstation immediately by using the PSEXEC.EXE tool. As a result, the SofTrack Local Workstation Agent is immediately installed (and started), allowing you to gain instant results from your SofTrack deployment.

In order to utilize this version of the "PUSH" system, you must first obtain the PSEXEC.EXE tool from Sysinternals, Inc. Once you have downloaded the PSEXEC.ZIP file, the PSEXEC.EXE file will need to be extracted from the archive, and placed in the root of the PSEXEC "PUSH" system folder. PSEXEC can be downloaded at the following URL:

http://www.sysinternals.com/files/psexec.zip

**********************
* "PUSH" COMPONENTS: *
**********************

Each version of the "PUSH" system is contained within it's own directory, titled AT or PSEXEC. Both directories contain the following files and subdirectories.

- LOOP.BAT
- IPLOOP.BAT (alternate to LOOP.BAT)
- PUSH.BAT
- LWASETUP.BAT
- LWAREMV.001 (helper file contained in the HELPER directory)
- STAGING (directory)
- HELPER (directory)
 
***************************
* COMPONENT DESCRIPTIONS: *
***************************

- LOOP.BAT:
This is the FIRST file to modify, and contains the list of machines to which you wish to push the LWA. Workstations can be addressed either by NETBIOS names (WINS) or by IP address. 

- IPLOOP.BAT: 
This file is provided as an alternative to LOOP.BAT, and can be used with either version of the "PUSH" system. By setting the "octet" variables within this file, administrators can target entire IP ranges (Class A, B, and C), or individual IP segments. This file works by "walking" through the specified range, and connecting to each target workstation within that range. It also includes a built-in fault check by first checking to see if the hidden C$ share on the target workstation is accessible. If IPLOOP.BAT is able to connect to the workstation, it then passes the IP address to PUSH.BAT to deploy the LWA, otherwise the script will skip that workstation and continue on to the next in the specified range. The use of IPLOOP.BAT has proven to be very useful in environments utilizing DHCP to assign IP addresses to workstations.

- PUSH.BAT:
This file is called by the LOOP.BAT file once for each workstation, and actually performs the push of the LWA. It works by performing steps A through D (see "Script Versions Defined" above), and finishes by either scheduling an AT task that executes the LWASETUP.BAT file at the predetermined time, or calls PSEXEC.EXE to immediately execute the LWASETUP.BAT file on the target workstation, depending on the which version of the "PUSH" system you are implementing.

- LWASETUP.BAT:
This file is pushed to the LWASETUP directory of each workstation, along with the necessary LWA components. It is either executed by the AT command at a predetermined time (within the LOOP.BAT file) or immediately executed by the PSEXEC command. The "MODE" of LWASETUP.BAT (installation or removal of the LWA) is set by a variable within the LWASETUP.BAT. This variable is described fully within the LWASETUP.BAT file itself. 

In addition, LWASETUP.BAT can be executed locally on each target workstation by opening a command prompt and executing LWASETUP.BAT (from within the LWASETUP directory), followed by either "-INSTALL" or "-REMOVE". This allows support personnel to locally install, or remove, the LWA without the use of the "PUSH" system.

- LWAREMV.001 (helper file contained in the HELPER directory)
This file is pushed to the "LWASETUP\HELPER" directory of each workstation. It is used ONLY in the removal of the LWA (if applicable) by LWASETUP.BAT. During the removal of the LWA, this file is renamed by LWASETUP.BAT from LWAREMV.001 to LWAREMV.REG, and then called by REGEDIT to remove registry keys used solely by the LWA. Once the removal of the LWA registry keys is complete, this file is then renamed from LWAREMV.REG to LWAREMV.001 to prevent the end user from inadvertently executing the file in the future.

- HELPER (directory):
This folder contains necessary "helper" files that will be pushed to each target workstation.

- STAGING (directory):
This folder needs to contain all of the LWA files that will be pushed to the target workstation. The files should be copied to this directory before you execute the push as they are the source for the target stations' LWASETUP folder. The files that should be copied here are:

STLWA_NT.EXE
STLWMON.SYS
NWLWA32.EXE
INVENTRY.EXE
STNW32.DLL
_SMBIOS_.EXE

The above files can be obtained from the "LWA\NT-2K-XP" and "TOOLS\INVENTRY" directories of the "Softrack_full.zip" archive, which is available for download at the following URL:

http://www.softwaremetering.com/outgoing/softrack_full.zip

************
* PROCESS: *
************

1) Determine which version of the "PUSH" system you plan to implement. Remember, if you choose to utilize the PSEXEC version of the "PUSH" system, you must first download PSEXEC.EXE from Sysinternals' web site.

2) Open each of the component batch files and examine the internal comments so that you become familiar with their functions. There are several variables in each batch file that need to be edited in order for the "PUSH" system to function. These variables are described in detail at the beginning of each file.

3) Modify the LOOP.BAT to include the names of the workstations you are targeting for the LWA.

4) Modify the PUSH.BAT variables to use a drive letter that is not in use on the station from which it is run, and specify the mode (INSTALL or UNINSTALL) in which the deployment will take place.

5) Modify the LWASETUP.BAT to have the correct Target Server name, "Load Delay", "LWA Status", and "Logging" mode. The "Target Server" is absolutely crucial, as it will determine to what server the LWA will send its reports! Again, each of these variables are defined in greater detail at the beginning of the each file.

IMPORTANT NOTE: Logging in LWASETUP.BAT can be either sent to a local file or displayed to the screen. When using the LWASETUP.BAT through the PSEXEC "PUSH" scripting system, it is highly recommended that the LOGGING mode be set to "DISPLAY". This will allow logging comments to be passed from the target workstation to the administrator's workstation, thus being logged in the PUSH.LOG file. If this variable is set to "FILE", logging comments will be saved to the INSTALL.LOG (default) file within the LWASETUP directory on each target workstation.

***************
* CONCLUSION: *
***************

This script has proven to be quite robust in testing in our labs and with some of our customers. It is expected that the person modifying/operating it will have sufficient skill to decipher these instructions to create a working system; however, we are happy to assist in the customization of the scripts to assist you if the need arises. If you run into a problem, or find an improvement, please feel free to contact us at support@softwaremetering.com.

**************
* DISCLAIMER *
**************

The "PUSH" scripting system is provided solely as a means to provide System Administrators with an alternate method of installing the SofTrack Local Workstation Agent (LWA). Use of this script is the sole responsibility of the user. If you are not the System Administrator of your network, please make sure you obtain the proper permissions prior to utilizing this tool.
