Code:
/////////////////////////////////////////////
// Network Logon Script //
/////////////////////////////////////////////
var netObj=new ActiveXObject("WScript.Network");
var shellObj=new ActiveXObject("WScript.Shell");
var objShellApp=new ActiveXObject("Shell.Application");
var userName=shellObj.ExpandEnvironmentStrings("%USERNAME%")+"";
var ecdl=(userName.indexOf("ecdl")>-1);
var sIsMapped=false;
var tmpPath, fsObj;
var pList=netObj.EnumPrinterConnections();
var dList=netObj.EnumNetworkDrives();
var nList=new Array();
var envLocation=shellObj.ExpandEnvironmentStrings("%LOCATION%");
var isStaffNotebook=(shellObj.ExpandEnvironmentStrings("%COMP_TYPE%")=="SNB");
var isAdminPC=(shellObj.ExpandEnvironmentStrings("%COMP_TYPE%")=="APC");
try{
netObj.RemoveNetworkDrive("R:",true,true);
netObj.RemoveNetworkDrive("P:",true,true);
}
catch(e){
//shellObj.Popup("Error eN110: Your network drives have not mapped correctly.\nPlease report this to a member of the ICT department.",10,"Network Error",48);
}
for(i=0;i<dList.length;i+=2){ //for each current drive
if(dList.Item(i).indexOf("S")>-1) sIsMapped=true; //determine if the home folder has been mapped to S:
}
if(!sIsMapped){ //if the home folder has not been mapped
try{
netObj.MapNetworkDrive("S:","\\\\server\\"+userName+"$",true); //try to map it
}
catch(e){}
}
try{
netObj.MapNetworkDrive("R:","\\\\server\\resources",true);
netObj.MapNetworkDrive("P:","\\\\server\\software$",true);
}
catch(e){}
try{
objShellApp.NameSpace("R:").Self.Name="Resources";
objShellApp.NameSpace("P:").Self.Name="[SYS_FILES]";
}
catch(e){}
try{
objShellApp.NameSpace("S:").Self.Name="My Network Documents";
}
catch(e){}
if((!isStaffNotebook)&&(!isAdminPC)){
//////////////////////////////////////////// - PRINTER LIST - ////////////////////////////////////////////
nList["ART"] =new Array("\\\\art-a1\\art_cl","\\\\svr-print\\art_cls")
nList["ARTL"] =new Array("\\\\svr-print\\art_cls","\\\\svr-print\\art_cl_a3")
nList["BIO"] =new Array("\\\\svr-print\\b2_ls","\\\\svr-print\\b3_ls","\\\\che-a2\\che_ls","\\\\svr-print\\che_cls","\\\\svr-print\\phy_cls","\\\\svr-print\\cr1_ls")
nList["CAR"] =new Array("\\\\svr-print\\car_ls")
nList["CHE"] =new Array("\\\\che-a2\\che_ls","\\\\svr-print\\che_cls","\\\\svr-print\\phy_cls","\\\\svr-print\\cr1_ls","\\\\svr-print\\b2_ls","\\\\svr-print\\b3_ls")
nList["CR1"] =new Array("\\\\svr-print\\cr1_ls","\\\\svr-print\\cr1_cls","\\\\svr-print\\cr1_cls_a3")
nList["CR2"] =new Array("\\\\svr-print\\cr2_ls","\\\\svr-print\\cr2_cls","\\\\svr-print\\cr2_cls_a3","\\\\svr-print\\cr1_cls_a3")
nList["CR3"] =new Array("\\\\svr-print\\cr3_ls","\\\\svr-print\\cr3_cls_a3")
nList["CR4"] =new Array("\\\\svr-print\\cr4_ls","\\\\svr-print\\lib_cls")
nList["CRO"] =new Array("\\\\svr-print\\nso_cls","\\\\svr-print\\cr1_ls","\\\\svr-print\\cr1_cls","\\\\svr-print\\cr1_cls_a3")
nList["DRA"] =new Array("\\\\dra-a1\\dra_cls","\\\\dra-a1\\dra_cph","\\\\dra-a1\\dra_ph")
nList["ENG"] =new Array("\\\\svr-print\\eng_ls","\\\\svr-print\\lib_ls","\\\\svr_print\\lib_cls")
nList["Ec"] =new Array("\\\\svr-print\\lib_ls","\\\\svr_print\\lib_cls")
nList["EXA"] =new Array("\\\\EXA-A1\\EXA_CLS")
nList["EXA_HST_CLS"]=new Array("HP Color LaserJet 3600")
nList["FEES"] =new Array("Samsung ML-6060 Series PCL6","\\\\bur-22\\val_ls")
nList["GEO"] =new Array("\\\\svr-print\cr3_ls","\\\\svr-print\\cr3_cls_a3")
nList["GEOO"] =new Array("\\\\svr-print\\cr3_cls_a3","\\\\svr-print\\cr3_ls")
nList["H2"] =new Array("\\\\svr-print\\his_cls")
nList["ITR"] =new Array("\\\\svr-print\\itr_ls")
nList["L3"] =new Array("\\\\svr-print\\l3_cl")
nList["LAN"] =new Array("\\\\svr-print\\lan_cls")
nList["LIB"] =new Array("\\\\svr-print\\lib_ls","\\\\svr-print\\lib_cls")
nList["MAT"] =new Array("\\\\mat-3\\mat_ls")
nList["MAT_HST_CL"] =new Array("\\\\mat-3\\mat_ls")
nList["MAT_HST_LS"] =new Array("HP LaserJet 1160","\\\\mat-2\\mat_cl")
nList["MR1"] =new Array("\\\\svr-print\\mr1_ls")
nList["PE"] =new Array("\\\\svr-print\\pe_ls","\\\\svr-print\\peo_cls")
nList["PE_HST_LS"] =new Array("PE Laser (HP 1200)","\\\\pe-2\\pe_cls","\\\\pe-1\\pe_cl")
nList["PE_HST_CLS"] =new Array("\\\\pe-wnb2\\pe_ls","\\\\pe-1\\pe_cl")
nList["PE_HST_CL"] =new Array("\\\\pe-wnb2\\pe_ls","\\\\pe-2\\pe_cls")
nList["PHY"] =new Array("\\\\svr-print\\phy_cls","\\\\che-a2\\che_ls","\\\\svr-print\\che_cls","\\\\svr-print\\b2_ls","\\\\svr-print\\b3_ls")
nList["PHYO"] =new Array("\\\\svr-print\\phy_ls","\\\\svr-print\\phy_cls","\\\\svr-print\\phy_cl")
nList["TECH"] =new Array("\\\\svr-print\\tec_cls","\\\\svr-print\\cr2_ls","\\\\svr-print\\cr2_cls","\\\\svr-print\\cr2_cls_a3","\\\\svr-print\\cr1_cls_a3")
nList["TECWS"] =new Array("\\\\tec-6\\tec_cl","\\\\tec-6\\tec_cl_a3","\\\\svr-print\\tec_cls","\\\\svr-print\\cr2_cls_a3")
nList["TEC_HST_CL"] =new Array("HP Deskjet 6200 Series","\\\\svr-print\\tec_cls","\\\\svr-print\\cr2_cls_a3")
if((envLocation!="%LOCATION%")&&(nList[envLocation])){ //if the EES Method has worked
var start=(nList[envLocation][0].indexOf("\\\\")>-1)? 0:1 //find the first NETWORK printer in the list
for(i=1;i<pList.length;i+=2){ //for each current printer
if(pList.Item(i).indexOf("\\")>-1){ //if it's a network printer
try{netObj.RemovePrinterConnection(pList.Item(i),true)} //remove it
catch(e){}}}
for(i=start;i<nList[envLocation].length;i++){ // for each listed printer
try{netObj.AddWindowsPrinterConnection(nList[envLocation][i])} // add it
catch(e){
try{netObj.AddWindowsPrinterConnection(nList[envLocation][i])}
catch(e2){
try{netObj.AddWindowsPrinterConnection(nList[envLocation][i])}
catch(e3){
}
}
}}
try{netObj.SetDefaultPrinter(nList[envLocation][0])} //set the first listed printer as default
catch(e){}}
start=null;
}
//Disable Accessibility Keys
shellObj.RegWrite("HKCU\\Control Panel\\Accessibility\\StickyKeys\\Flags","506","REG_SZ");
shellObj.RegWrite("HKCU\\Control Panel\\Accessibility\\HighContrast\\Flags","122","REG_SZ");
shellObj.RegWrite("HKCU\\Control Panel\\Accessibility\\MouseKeys\\Flags","58","REG_SZ");
shellObj.RegWrite("HKCU\\Control Panel\\Accessibility\\ToggleKeys\\Flags","58","REG_SZ");
// Empty the trash
netObj=null;
shellObj=null;
objShellApp=null;
pList=null;
nList=null;
envLocation=null;
isNotebook=null;
ecdl=null;
tmpPath=null;
fsObj=null;
WScript.Quit();