This script was created to allow users to control which drives are mapped to which shares. Simply, the user creates an INI file (@USERID.INI) and the script maps what they specified. If there is not file, it just skips it. I also use this script to perform all drive mappings and allow group admins to change their drive mappings, without having to code KiXtart. NOTE, you need KiXtart 3.62 or higher to use this script (arrays): ;--------------------------
$MAPINI = @LDRIVE + "\INI\USERS\@USERID.INI" ; Specifies which INI file to obtain drive mappings from
IF EXIST($MAPINI)
GOSUB MAPINIDRIVES
ENDIF
GOTO END
:MAPINIDRIVES
;--------------------------
Maps drives specified in an INI file.
;--------------------------
$DRIVES = 21 ; Maximum number of drives to map (24 - 3). DO NOT CHANGE!
DIM $DLETTER[$DRIVES] ; Drive Letter Array. Arrays start at 0, not 1
DIM $DSHARE[$DRIVES] ; Drive Share Array. Arrays start at 0, not 1
$INISHARE = "" ; Current share read from INI file
$DNUM = 68 ; "D" Starting drive letter
$ACOUNT = 0 ; Array content count. Must be 0 or will error!
DO
$INISHARE = READPROFILESTRING("$MAPINI", "DRIVES", CHR($DNUM) + ":")
IF ($INISHARE <> "") AND @ERROR = 0
IF SUBSTR($INISHARE,1,2) = "\\"
$DLETTER[$ACOUNT] = CHR($DNUM) + ":"
$DSHARE[$ACOUNT] = $INISHARE
$ACOUNT = $ACOUNT + 1
ELSE ; Incorrect UNC format within the INI file
$RCODE = MESSAGEBOX ("There is an incorrect entry within the file: $MAPINI" + CHR(10) + CHR(10) + "ENTRY: " + CHR($DNUM) + ":=$INISHARE" + CHR(10) + CHR(10) + "TIP: All entries should comply to the format: DRIVE:=\\SERVER\SHARE", "ERROR: INCORRECT INI ENTRY", 0, 20)
ENDIF
ENDIF
$DNUM = $DNUM + 1
$INISHARE = ""
UNTIL ($DNUM = 91) ; "Z" Ending drive letter
$INDEX = 0
WHILE $INDEX <> $ACOUNT
AT($Row,6) " Mapping Drive " + $DLETTER[$INDEX] + " to " + $DSHARE[$INDEX] + " ... "
USE $DLETTER[$INDEX] /DELETE ; Remove old drive mapping
USE $DLETTER[$INDEX] $DSHARE[$INDEX] ; Attempt to map drive
SELECT
CASE @ERROR = 0
$STATUS = " " + CHR(251) + " OK" ; No errors
CASE (@ERROR = 15) OR (@ERROR = 85) OR (@ERROR = 1202)
$STATUS = "ERROR" ; Drive letter in use
$RCODE = MESSAGEBOX ("The drive " + $DLETTER[$INDEX] + " cannot be mapped to the specified share (" + $DSHARE[$INDEX] + ") because the drive letter is either in use or unavailable.", "ERROR: (" + @ERROR + ") " + @SERROR, 0, 20)
CASE (@ERROR = 3) OR (@ERROR = 11) OR (@ERROR = 53) OR (@ERROR = 67) OR (@ERROR = 161) OR (@ERROR = 1214) OR (@ERROR = 1215)
$STATUS = "ERROR" ; Share not available
$RCODE = MESSAGEBOX ("The drive " + $DLETTER[$INDEX] + " cannot be mapped to the specified share (" + $DSHARE[$INDEX] + ") because it is either invalid or cannot be accessed at the current time.", "ERROR: (" + @ERROR + ") " + @SERROR, 0, 20)
CASE 1
$STATUS = " ??"
ENDSELECT
AT($ROW,65) "$STATUS"
$ROW = $ROW + 1
$INDEX = $INDEX + 1
LOOP
RETURN
:END
;--------------------------
Example INI file:
[DRIVES]
Q:=\\SERVER1\SHARE1
R:=\\SERVER2\SHARE1
G:=\\SERVER9\SHARE2
;-----------------------------
------------------
Jesse
------------------
For more scripting help and examples, click here.