Try this out...I just made a few changes.
1. Turned on the NoVarsInStrings setting so that you wont have to change all of the drives that end with $. $ is a special char in kix and should be doubled up if you want them included in a string (unless of course you set NoVarsInStrings).
2. Removed the first IF statement since it wasnt really needed. All the client OSs you mentioned (nt,2k,xp) should be able to handle the @UserID macro and that was the only difference I noticed.
3. Indented all of the code to make it easier to understand/read. Please post any code in between code tags to preserve and indenting in the future.
4. Removed a REM statement towards the bottom. That is a DOS command not a kix command. Use the ; to comment lines in a kix script.
5. Removed any variables from quotes so that the NoVarsInStrings does not break them. Hopefully I didn't miss any.
I couldnt really test it any since all of the drive mappings would fail for me anyways. So let us know how it works.
Code:
$null = SetOption("NoVarsInStrings","On")
? @kix
? @dos
? @ldrive
;;USE "*" /delete ;-- commented this out as the MapDrive function takes this into account
;;? "delete persistent mappings: "
? "mapping h: to homeshare: "
MapDrive("h:", "bstl_svr3", @UserID+"$")
SELECT
CASE Ingroup ("MK00")
MapDrive("i:", "bstl_svr3", "DocMK11$")
MapDrive("j:", "bstl_svr3", "DocMK12$")
MapDrive("k:", "bstl_svr3", "DocMK13$")
MapDrive("l:", "bstl_svr3", "DocMK21$")
MapDrive("m:", "bstl_svr3", "DocMK32$")
MapDrive("n:", "bstl_svr3", "DocOE11$")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("MK10")
MapDrive("i:", "bstl_svr3", "DocMK11$")
MapDrive("j:", "bstl_svr3", "DocMK12$")
MapDrive("k:", "bstl_svr3", "DocMK13$")
MapDrive("l:", "bstl_svr3", "DocMKPublic$")
MapDrive("m:", "bstl_svr3", "DocMK11$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK1")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK2")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK3")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK6")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("MK11")
MapDrive("i:", "bstl_svr3", "DocMK11$")
MapDrive("j:", "bstl_svr3", "Winsurvey")
MapDrive("l:", "bstl_svr3", "DocMKPublic$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK1")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK2")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK3")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK6")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("MK12")
MapDrive("i:", "bstl_svr3", "DocMK12$")
MapDrive("j:", "bstl_svr3", "Winsurvey")
MapDrive("k:", "bstl_svr3", "DocMKPublic$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK1")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK2")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK3")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK6")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("MK13")
MapDrive("i:", "bstl_svr3", "DocMK13$")
MapDrive("j:", "bstl_svr3", "Winsurvey")
MapDrive("k:", "bstl_svr3", "DocRD11$")
MapDrive("l:", "bstl_svr3", "Lindav$")
MapDrive("m:", "bstl_svr3", "DocMKPublic$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK1")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK2")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK3")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK6")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("MK21")
MapDrive("i:", "bstl_svr3", "DocMK21$")
MapDrive("j:", "bstl_svr3", "Winsurvey")
MapDrive("k:", "bstl_svr3", "DocMKPublic$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK1")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK2")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK3")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK6")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("MK32")
MapDrive("i:", "bstl_svr3", "DocMK32$")
MapDrive("j:", "bstl_svr3", "Winsurvey")
MapDrive("k:", "bstl_svr3", "DocMKPublic$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK1")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK2")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK3")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK6")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("S01")
MapDrive("i:", "bstl_svr3", "DocOE11$")
MapDrive("j:", "bstl_svr3", "DocMK21$")
CASE Ingroup ("OE11")
MapDrive("i:", "bstl_svr3", "DocOE11$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSMK4")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL01")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL00")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL11")
MapDrive("i:", "bstl_svr3", "DocSL11$")
MapDrive("j:", "bstl_svr3", "Winsurvey")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL12")
MapDrive("i:", "bstl_svr3", "DocSL12$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL13")
MapDrive("i:", "bstl_svr3", "DocSL13$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL14")
MapDrive("i:", "bstl_svr3", "DocSL14$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL15")
MapDrive("i:", "bstl_svr3", "DocSL15$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL16")
MapDrive("i:", "bstl_svr3", "DocSL16$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL17")
MapDrive("i:", "bstl_svr3", "DocSL17$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL18")
MapDrive("i:", "bstl_svr3", "DocSL18$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SL41")
MapDrive("i:", "bstl_svr3", "DocSL41$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("XA11")
MapDrive("i:", "bstl_svr3", "DocXA11A$")
MapDrive("j:", "bstl_svr3", "DocXA11B$")
MapDrive("k:", "bstl_svr3", "DocXA11C$")
MapDrive("l:", "bstl_svr3", "DocXA11D$")
MapDrive("M:", "bstl_svr3", "DocXA11$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSAC2")
MapDrive("n:", "bstl_svr3", "SAP_BSTLAC$")
MapDrive("o:", "bstl_svr3", "SAP$")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("XA11A")
MapDrive("i:", "bstl_svr3", "DocXA11A$")
MapDrive("j:", "bstl_svr3", "DocXA11$")
MapDrive("k:", "bstl_svr3", "SAP_BSTLAC$")
MapDrive("l:", "bstl_svr3", "SAP$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSAC2")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("XA11B")
MapDrive("i:", "bstl_svr3", "DocXA11B$")
MapDrive("j:", "bstl_svr3", "DocXA11$")
MapDrive("k:", "bstl_svr3", "SAP_BSTLAC$")
MapDrive("l:", "bstl_svr3", "SAP$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSAC2")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("XA11C")
MapDrive("i:", "bstl_svr3", "DocXA11C$")
MapDrive("j:", "bstl_svr3", "DocXA11$")
MapDrive("k:", "bstl_svr3", "SAP_BSTLAC$")
MapDrive("l:", "bstl_svr3", "SAP$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSAC2")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("XA11D")
MapDrive("i:", "bstl_svr3", "DocXA11D$")
MapDrive("j:", "bstl_svr3", "DocXA11$")
MapDrive("k:", "bstl_svr3", "SAP_BSTLAC$")
MapDrive("l:", "bstl_svr3", "SAP$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSAC2")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("XA12")
MapDrive("i:", "bstl_svr3", "DocXA12$")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("EDP")
MapDrive("i:", "bstl_svr3", "DocEDP$")
MapDrive("j:", "bstl_svr3", "Software$")
MapDrive("k:", "bstl_svr3", "DocXA12$")
MapDrive("l:", "bstl_svr3", "SAP$")
MapDrive("m:", "bstl_svr3", "TRASDoc$")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("EDP1")
MapDrive("i:", "bstl_svr3", "DocEDP$")
MapDrive("j:", "bstl_svr3", "dept$")
MapDrive("k:", "bstl_svr3", "users$")
MapDrive("l:", "bstl_svr3", "Software$")
MapDrive("m:", "bstl_svr3", "SAP$")
MapDrive("n:", "bstl_svr3", "TRASDoc$")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("EDPADMIN")
MapDrive("i:", "bstl_svr3", "DocEDP$")
MapDrive("j:", "bstl_svr3", "dept$")
MapDrive("k:", "bstl_svr3", "users$")
MapDrive("l:", "bstl_svr3", "Software$")
MapDrive("m:", "bstl_svr3", "SAP$")
MapDrive("n:", "bstl_svr3", "TRASDoc$")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("RD11")
MapDrive("i:", "bstl_svr3", "DocRD11$")
MapDrive("j:", "bstl_svr3", "Lindav$")
AddPrinterConnection("\\BSTL_SVR1\PRTLSSL4")
AddPrinterConnection("\\BSTL_SVR1\Deskjet5550")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("TS")
MapDrive("i:", "bstl_svr3", "DocTS$")
Shell "\\bstl_svr1\ofcscan\autopcc.exe"
CASE Ingroup ("SALESDEPT")
MapDrive("m:", "bstl_svr3", "ShareDoc")
CASE Ingroup ("SAPGROUP")
MapDrive("i:", "bstl_svr3", "SAP$")
MapDrive("j:", "bstl_svr3", "TRASDoc$")
ENDSELECT
; GET $
FUNCTION MapDrive($drive, $server, $share)
DIM $drive, $server, $share
COLOR c+/n
IF $drive<>"" AND $server<>"" AND $share<>""
$logtext="Connecting $Drive to \\$Server\$Share"
? $logtext
USE $drive /delete /persistent
USE $drive "\\$Server\$Share"
IF @error=0
COLOR g+/n
$x=" - Success"
$x
ELSE
COLOR r+/n
$x=" - Failed: Error @error"
$x
$errorstate=1
ENDIF
WriteLog ($logtext + $x)
COLOR w+/n
ELSE
WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'")
ENDIF
ENDFUNCTION
FUNCTION WriteLog($text)
DIM $rc, $text, $logfile, $filehandle
$filehandle = 1
$logfile = "%temp%\logon.log"
$rc=Writeline ($filehandle, "@Date @Time - $Text" + Chr(13) + Chr(10))
IF $rc<0
$rc=Close ($filehandle)
$rc=Open ($filehandle, $LogFile, 5)
SELECT
CASE
$rc=-1
$rc=MessageBox ("Invalid file name ($LogFile) specified for log file.","Logon Script Error",48)
CASE
$rc=0
WriteLog ($text)
CASE
$rc=>0
$rc=MessageBox ("Error($RC) while attempting to open log file ($LogFile).","Logon Script Error",48)
ENDSELECT
ENDIF
ENDFUNCTION