;Thomas Coleman
;Map drives used by all users
;User Drives
$=SetOption("Explicit","ON")
Global $__MESSAGELEVEL
$__MESSAGELEVEL=9 ; ** Change this value to set the level of messages to display, "-1" suppresses all messages
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; FUNCTION DEFINITION SECTION STARTS
; Message UDF - display a message on the console if allowed by message level
Function Message($sMessage,optional $iLevel)
If $__MESSAGELEVEL>=CInt($iLevel) $sMessage EndIf
Exit 0
EndFunction
; Map a drive, report errors
Function MapDrive($sLetter, $sUNC)
Message("Mapping "+$sLetter+" to "+$sUNC+@CRLF, 7)
Use $sLetter /delete /persistent
Use $sLetter $sUNC
$MapDrive=@ERROR
If @ERROR
Message("ERROR: Failed to map "+$sLetter+" to "+$sUNC+@CRLF+" Reason: ["+@ERROR+"] "+@SERROR+@CRLF)
Else
Message(" Drive mapped OK",9)
EndIf
Exit $MapDrive
EndFunction
; Map a printer, report errors
Function MapPrinter($sPrinter)
Message("Connecting printer "+$sPrinter+@CRLF, 7)
$MapPrinter=AddPrinterConnection($sPrinter)
If @ERROR
Message("ERROR: Failed to connect printer "+$sPrinter+@CRLF+" Reason: ["+@ERROR+"] "+@SERROR+@CRLF)
Else
Message(" Printer connected OK",9)
EndIf
Exit $MapPrinter
EndFunction
; FUNCTION DEFINITION SECTION ENDS
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Dim $sGroup
USE * /delete
$=MapDrive("h:","\\pamplona-dfsfs2\users\"+%USERNAME%)
; You can set the default printer using the following command
; NB. When using the set default printer command it uses the Name of the printer on the server not
; the unc share name - these are not necessarily the same
; SetDefaultPrinter ("\\pamplona-dfsfs2\printershare")
; To delete a printer use the following command
; This also uses the printer name not the UNC path (even though it looks like a UNC path)
; DelPrinterConnection ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
;To map drives based on user
If @userid = "lady"
$=MapDrive("x:","\\pamplona-dfsfs2\awiredu" )
EndIf
; Map drive for administrator with Installation files
$sGroup="Administrators"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("s:","\\PAMPLONA-DFSFS2\IT$")
EndIf
; Map drives and printers for users by group membership
$sGroup="Fund of Funds"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("j:","\\pamplona-dfsfs2\fund of funds")
MapPrinter("\\pamplona-dfsfs2\HP LaserJet 4350 FOF")
MapPrinter("\\pamplona-dfsfs2\HP3800 FOF Window Bay")
MapPrinter("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
$=SetDefaultPrinter("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
EndIf
$sGroup="PCO ALL"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("s:","\\pamplona-dfsfs2\PCO Marketing")
$=MapDrive("y:","\\pamplona-dfsfs2\PCO Fund")
MapPrinter("\\pamplona-dfsfs2\HP Color LaserJet 3800 PCO")
MapPrinter("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
EndIf
$sGroup="Private Equity"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("p:","\\pamplona-dfsfs2\private equity")
MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
$=SetDefaultPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf
$sGroup="IVA"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("i:","\\sqlpco\iva")
MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf
$sGroup="oakwood"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("o:","\\sqlpco\oakwood")
MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf
$sGroup="finance"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("f:","\\pamplona-dfsfs2\finance")
MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf
$sGroup="infrastructure"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("q:","\\pamplona-dfsfs2\infrastructure")
MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf
$sGroup="Reception"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
$=SetDefaultPrinter("\\pamplona-dfsfs2\4th_Floor_Reception-HP_CP3525")
EndIf
$sGroup="Hedge Fund"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("z:","\\pamplona-dfsfs2\hedge fund")
EndIf
$sGroup="General"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("g:","\\pamplona-dfsfs2\General")
EndIf
$sGroup="HR"
If InGroup($sGroup)
Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
$=MapDrive("r:","\\pamplona-dfsfs2\hr")
EndIf