Sharing Scripts Across Different Workstation Platforms
Articles and Tips: tip
01 Aug 1996
We have a number of workstations that are being used 24 hours a day by up to four different people. With this type of operation, the maintenance calls that we get from users about the third shift screwing up the first shift's desktops became too like much work. Not wanting to use a shared copy of Windows 3.x, I created a login procedure that allows users to log on to different workstations and still keep a different desktop for each one.
All references to the local drive assume that the path to Windows on the local drive is C:\WINDOWS. When the files are copied to and from the local drive or the network drive, the existing directory structure is preserved so that files are always copied to and from the correct locations.
In the system login script, I added the following code:
IF MEMBER OF "SHARED" THEN BEGIN DOS SET WKST=P_STATION DOS SET USER=LOGIN_NAME DOS SET WK_SHARE=YES END
Next, I created a Group called SHARED and placed everyone that would be sharing a workstation into this Group.
Using QuickBasic, I created an executable program that reads in WKST which contains the 12 hex characters of the NIC node address. The right-most eight characters of WKST are used to create a directory name (for example: the P_STATION address is read in as 00AA0023DC1F and is then converted to 0023DC1F). I did this because we had ordered our NICs by the case and noticed that some of the cards were very close in addressing. If I had used the left-most eight characters, I would have run the risk of having more that one workstation with the same address after the conversion. For example, 00AA003C001A and 00AA003CECDA would both convert to 00AA003C.
At login, each user executes a system batch file that performs numerous functions. For instance, each Wednesday the batch file runs a DEFRAG program on the local drive; each day the batch file runs SCANDISK and a virus detection program on the local drive; and so forth. Within this batch file I placed the following code:
IF NOT '%WK_SHARE%'=='YES' GOTO NO_SHARE ;if not a member of SHARED group then skip next line #LOADCFGS LOGIN H:\USERS\%USER%\CFGS\ ;execute program :NO_SHARE
At logout, when a member of the group SHARED exits Windows, that user executes LOADCFGS again. This attempts to create the directory pointed to by [path] and the NIC address. If the directory exists, the user has logged to this workstation before and error routines handle this problem. If the directory does not exist, it is created. Either way, the file types specified on the command line are then copied from the local drive to [path] and NIC address.
The following code is placed in the system batch file:
<Windows exits here> more batch code................................... IF NOT '%WK_SHARE%'=='YES' GOTO SHARE_NOT ;if not a member of SHARED then skip next 2 lines #LOADCFGS LOGOUT H:\USERS\%USER%\CFGS\ INI GRP SET INF DAT PIF CFG LOGOUT :SHARE_NOT ...................................
(The information as to what is copied through the LOADCFGS utility is covered in the QuickBasic 4.5 Source Code section.)
The typical directory structure would be:
H:\USERS\FJONES\CFGS\0023DC1F\<files> H:\USERS\FJONES\CFGS\00CF012F\<files> H:\USERS\FJONES\CFGS\0C2312AC\<files>
I also included addition code in the system batch file to track for a date change. This way, the file loading occurred only at the initial boot-up of the new day. If the machine was re-booted during that same day then the LOADCFGS program did not execute at each bootup.
If for some reason, the files need to be saved or loaded again after bootup, all you have to do is go to the DOS prompt, type SET to display the values in USER & WKST, and then run the LOADCFGS program from the DOS prompt. You can also write a batch file with replaceable parameters to do the job.
I hope that this is of use. If anyone would like the EXE for CFGS, send an e-mail to email@example.com and place CFGS EXE in the subject field.
QuickBasic 4.5 Source Code ************************************************ 'CFGS.BAS (C)1994 Gordon H Gosch ' DECLARE SUB Comline (N%, A$(), Max%) DIM Dname$, CmdArg$(1 TO 15), Xcopy$, I%, N% ON ERROR GOTO Eroutine CLS IF ENVIRON$("USER") = "" OR ENVIRON$("WKST") = "" OR COMMAND$ = "" THEN END CALL Comline(N%, CmdArg$(), 15) IF LEN(CmdArg$(2)) = 0 THEN END Dname$ = UCASE$(LTRIM$(RTRIM$(CmdArg$(2)))) Dname$ = Dname$ + UCASE$(RIGHT$(ENVIRON$("WKST"), 8)) IF UCASE$(CmdArg$(1)) = "LOGIN" THEN Xcopy$ = "XCOPY " + Dname$ + "\*.* C:\WINDOWS " + "/S /V /Y" SHELL Xcopy$ ELSEIF UCASE$(CmdArg$(1)) = "LOGOUT" THEN IF LEN(CmdArg$(3)) = 0 THEN END MKDIR Dname$ FOR I% = 3 TO N% Xcopy$ = "XCOPY C:\WINDOWS\*." + CmdArg$(I%) + " " + Dname$ + "\ /S /V /Y" SHELL Xcopy$ NEXT END IF END Eroutine: RESUME NEXT **************************************************************** This routine is an example from Microsoft QuickBasic 4.5 DEFINT A-Z SUB Comline (NumArgs%, Args$(), MaxArgs%) STATIC CONST TRUE = -1, FALSE = 0 NumArgs = 0 in = FALSE Cl$ = COMMAND$ L = LEN(Cl$) FOR I = 1 TO L C$ = MID$(Cl$, I, 1) IF (C$ <> " " AND C$ <> CHR$(9)) THEN IF NOT in THEN IF NumArgs% = MaxArgs% THEN EXIT FOR NumArgs% = NumArgs% + 1 in = TRUE END IF Args$(NumArgs%) = Args$(NumArgs%) + C$ ELSE in = FALSE END IF NEXT I END SUB
* Originally published in Novell AppNotes
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.