+ Post New Thread
Results 1 to 10 of 10
Windows Server 2000/2003 Thread, .JS Logon script – Printers randomly not connecting in Technical; ...
  1. #1

    Join Date
    Apr 2009
    Posts
    93
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    15

    .JS Logon script – Printers randomly not connecting

    Hi all,

    I have just started a new job as an IT Tech in a school. We use a javascript (.js) logon script which connects to a set of network printers depending on the location of the PC.

    In the last couple of days, things has been playing up. Randomly printers will not connect. Sometimes all the printers and sometimes only 1 or 2 of the printers and sometimes none of the printers.

    I don’t think that it is a problem with the script, as it has been working fine previously. Also the fact that sometimes all the printers are connected fine and other times not suggests to me that it is more likely to be some kind of maximum connection problem or something.

    Anyway, i have been looking round the web for the last day or so without much luck.....has anyone got any ideas for things I can try?

    The only change recently is that I updated the driver for one of the printers on the server.

    Many thanks

  2. #2
    d1b5's Avatar
    Join Date
    May 2009
    Location
    London
    Posts
    9
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hi, am i right in saying that some of the PC's are/should be connecting to more than one network printer when they logon???? or are you saying that if I log on to the network at one part of the school (maths room) I want to see only the maths room network printer?


    is it possible to have a look at you script? also I have had this before and some times putting a shortcut of the script on the desktops so that they can run if it does not map properly is a workaround until its fixed.

  3. #3

    Join Date
    Apr 2009
    Posts
    93
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    15
    Quote Originally Posted by d1b5 View Post
    Hi, am i right in saying that some of the PC's are/should be connecting to more than one network printer when they logon???? or are you saying that if I log on to the network at one part of the school (maths room) I want to see only the maths room network printer?


    is it possible to have a look at you script? also I have had this before and some times putting a shortcut of the script on the desktops so that they can run if it does not map properly is a workaround until its fixed.
    yeah must admit, I have been thinking about the a shortcut as a work around but its not ideal if we can avoid it. Also (as I just found out) sometimes you need to run the script up to 10 times to get the printer to appear....I am sure this must be some kind of time out or something.

    In regards to your first question, the printers that are connected should depend on the location in the school. For example:

    A Pc in the Library should have access to the 'Library Laser' and the 'Library Colour Laser':
    On the PC in Library we add the Envoronmental Variable 'LOCATION' with the value 'LIB'
    The script then looks for this 'LIB' and assigns it the appropriate printers.
    However, only the 'Library laser' was connected and not the 'Library Colour Laser'. Several manual script runs later, both printers will finally appear.

    I dont think it is a problem with the script as it has always run fine in the past, and it does work manually eventually. Also the problem is completely random in terms of location in the school (e.g. The Library might be fine for a week now, and then randomly the problem will start again)

    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();

  4. #4
    d1b5's Avatar
    Join Date
    May 2009
    Location
    London
    Posts
    9
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    OK, what you could try is deleting the variables and then re-creating them again with the existing name (LIB) or create a new variable name on the PC and change the script so it looks for the new variable, is there any way that you can use the force command in the JS script to tell the PC to connect to the desired printer???

    1 more thing is to try and install con2print. its exactly what you need to do and its what i use at all of the schools that i look after.

    here is the download link........ its all basic scripting, you just unzip and paste the con2print.exe into your Netlogon folder and create a new .bat file calling con2print. any probs message me.

    http://thisishelpful.com/Downloads/p...1/p13_fileid/1

    Hope this might help.

  5. #5

    Join Date
    Apr 2009
    Posts
    93
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    15
    Quote Originally Posted by d1b5 View Post
    OK, what you could try is deleting the variables and then re-creating them again with the existing name (LIB) or create a new variable name on the PC and change the script so it looks for the new variable, is there any way that you can use the force command in the JS script to tell the PC to connect to the desired printer???

    1 more thing is to try and install con2print. its exactly what you need to do and its what i use at all of the schools that i look after.

    here is the download link........ its all basic scripting, you just unzip and paste the con2print.exe into your Netlogon folder and create a new .bat file calling con2print. any probs message me.

    http://thisishelpful.com/Downloads/p...1/p13_fileid/1

    Hope this might help.

    Thanks for your help.

    I don't really want to start looking down the route of switching the script to a different method at the moment (wouldnt be up to me anyway!), but I will certianly try your other ideas.

    Just seems strange as the script appears to run perfectly fine on all machines for 95% of the time, they just randomly seem to have these blipps(its only started happening in the last few weeks) so im not sure changing/refreshing the 'Location' variable will help....especially due to the fact that most of the time it goes wrong, it will still connect to 1 of the printers which you would not expect if there was a problem with the 'Location' variable.

  6. #6
    d1b5's Avatar
    Join Date
    May 2009
    Location
    London
    Posts
    9
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    True, it does seem a little weird, Sorry I cant be any more help to you, i have experienced this in the past and sometimes just re-creating the var normally works.. if you do manage to solve let me know...

    thanks

  7. #7

    Join Date
    Apr 2009
    Posts
    93
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    15
    Quote Originally Posted by d1b5 View Post
    True, it does seem a little weird, Sorry I cant be any more help to you, i have experienced this in the past and sometimes just re-creating the var normally works.. if you do manage to solve let me know...

    thanks

    cool, will give it a go this afternoon....it always gives you that bit more confidence when someone says that they have experienced it themselves!

    thanks again, will let you know how I get on

  8. #8

    Join Date
    Apr 2009
    Posts
    93
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    15
    We might finally have a breakthrough!

    ...and it looks like nothing at all related to everything I was guffing on about!

    Looks like when I updated an HP driver on the print server recently, it also installed something called hpboid.exe, which is some kind of HP status server. There was about 10 instances of it running in processes....

    just a quick google search for hpboid.exe suggests loads of issues with it causing delays etc. We have stopped the service's related, deleted the running processes and touch wood.....so far so good!

    Time will tell I guess.

    Thanks again for your help

  9. #9
    d1b5's Avatar
    Join Date
    May 2009
    Location
    London
    Posts
    9
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    cool, thats a bit weird, was the driver the basic driver from the HP website? or was the full package? its sounds like the full package and with that it has installed an additional piece of software. im glad that has hopefully fixed it

  10. #10

    Join Date
    Apr 2009
    Posts
    93
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    15
    Quote Originally Posted by d1b5 View Post
    cool, thats a bit weird, was the driver the basic driver from the HP website? or was the full package? its sounds like the full package and with that it has installed an additional piece of software. im glad that has hopefully fixed it
    I thought it was just the basic drivers, could be wrong though...it was a couple of weeks ago now :-/

SHARE:
+ Post New Thread

Similar Threads

  1. Logon Script Not on 1 PC
    By karldenton in forum Windows
    Replies: 1
    Last Post: 25th March 2009, 12:05 PM
  2. Terminal server logon script for printers
    By cookie_monster in forum Scripts
    Replies: 11
    Last Post: 13th August 2008, 11:46 AM
  3. Printers logon script error messages
    By indie in forum Windows
    Replies: 1
    Last Post: 14th September 2007, 11:34 AM
  4. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM
  5. Problem assigning printers at logon - SOLVED
    By richard in forum Wireless Networks
    Replies: 12
    Last Post: 4th January 2007, 09:14 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •