+ Post New Thread
Results 1 to 12 of 12
Scripts Thread, Printer script not running at start up in Coding and Web Development; My boss made a new printer script and it works locally but when we tries to deploy it as a ...
  1. #1
    richard
    Guest

    Printer script not running at start up

    My boss made a new printer script and it works locally but when we tries to deploy it as a startup script it fails to run at all. Its been added as startup script to the relevant OU but no matter what we try it doesn't work. Any ideas?

  2. #2

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,596
    Thank Post
    109
    Thanked 764 Times in 595 Posts
    Rep Power
    181

    Re: Printer script not running at start up

    Printers are a per user setting (unless they are a locally attached printer). Why not use my VBScript and run it at logon?

  3. #3

    Join Date
    Mar 2007
    Location
    Central Scotland
    Posts
    829
    Thank Post
    12
    Thanked 8 Times in 8 Posts
    Rep Power
    19

    Re: Printer script not running at start up

    Richard is is similar to this when you open up the script?

    rundll32 printui.dll,PrintUIEntry /ga /n"\\print\HPLJ2300 BS1"

    We use scripts like that in a batch file run once on the local computer to set the printers for all users on that PC. I haven't tried it but I don't see any reason why it wouldn't work - although perhaps it's a rights issue if the user isn't allowed to add printers. We run it as an administrator, pretty sure it won't work here as a normal user.

    As Ric says I think running one as a VBscript somehow would work, done that in the past for other items but not entirely sure what script you'd need in this instance.

  4. #4
    richard
    Guest

    Re: Printer script not running at start up

    Here's the vbs script that he's written

    Code:
    Option Explicit
    Dim objNetwork, strLocal, strUNCPrinter1, strUNCPrinter2
    strUNCPrinter1 = "\\Server1d\RICOHMA"
    
    Set objNetwork = CreateObject("WScript.Network") 
    objNetwork.AddWindowsPrinterConnection strUNCPrinter1
    
    objNetwork.SetDefaultPrinter "\\Server1d\RICOHMA"
    
    
    WScript.Quit
    Its been set as a startup script in the computer configuration. I have also tried to run it when a user logs in but to no avail.

  5. #5
    tosh74's Avatar
    Join Date
    Dec 2006
    Location
    Scotland
    Posts
    136
    Thank Post
    27
    Thanked 43 Times in 27 Posts
    Rep Power
    23

    Re: Printer script not running at start up

    Printer scripts do not run as a Computer startup script. You need to assign the script to the USER startup script

    ie USER CONFIGURATION\WINDOWS SETTINGS\SCRIPTS (LOGON/LOGOFF)\LOGON


    You could edit your script so that it looks at the machine name and decide what printer map. Here's mine
    Code:
    ' automated printer redirection setup for users as script fails for machine startup
    ' if the printer is OFF then the script will fail
    ' what if the printer is not in the list of installed printers??
    
    Option Explicit
    DIM RegEntry, ComputerName
    RegEntry="HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
    ComputerName = ReadRegValue(RegEntry)
    
    'if InStr(1,ucase(ComputerName),"Part or whole machine name",vbTextCompare) > 0 then call SetPrinter("\\Server\Printershare")
    if InStr(1,ucase(ComputerName),"Admin",vbTextCompare) > 0 then call setPrinter("\\Server\AdminPrinter")
    
    
    
    ' keep adding lines for each location – modify just the sections in quotes as needed
    wscript.quit
    
    ' ***  This subroutine installs and sets the default printer
    Sub SetPrinter(ByVal PrinterPath)
      On Error Resume Next
      DIM WshNetwork
      Set WshNetwork = CreateObject("WScript.Network")
      WshNetwork.AddWindowsPrinterConnection(PrinterPath)
      WshNetwork.SetDefaultPrinter Printerpath
    end sub
    
    ' ****  This function returns the data in the registry value
    Function ReadRegValue(ByVal RegValue)      
      DIM WSHShell
      Set WSHShell = WScript.CreateObject("WScript.Shell")
      ReadRegValue=""
      On Error Resume Next
      ReadRegValue= WSHShell.RegRead(RegValue)
    End Function

  6. #6

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,804
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Printer script not running at start up

    Printer scripts do not run as a Computer startup script. You need to assign the script to the USER startup script
    This may not be sufficient. If the user does not have enough access to the machine to install drivers, the printer will not work. You can get round this by running the printer script at machine start-up though and pre loading the drivers.

    If in doubt, I suggest you run the printer script both at computer start-up and user login. Unless you're overly concerned about machine start-up times of course.

  7. #7
    MicrodigitUK's Avatar
    Join Date
    May 2007
    Location
    Wiltshire
    Posts
    334
    Thank Post
    37
    Thanked 55 Times in 51 Posts
    Rep Power
    24

    Re: Printer script not running at start up

    I have start-up batch file scripts setup so that the different groups in Active Directory install different printers at start-up by running the correct script for the room grouping. I do this by using the rundll32 printui.dll,PrintUIEntry command and they look a bit like this.

    Code:
    rundll32 printui.dll,PrintUIEntry /dl /n "HP Color LaserJet 3700 in D26" /q
    
    rundll32 printui.dll,PrintUIEntry /dl /n "HP B&W LaserJet 3700 in D26" /q
    
    rundll32 printui.dll,PrintUIEntry /u /if /b "HP Color LaserJet 3700 in D26" /f "\\jogdom.local\NETLOGON\InstallPrinters\Drivers\HP LJ 3700n\hpc3700c.inf" /r "\\JOGSERV01\hp3700n-002$" /m "HP Color LaserJet 3700 PCL 6" /q
    
    rundll32 printui.dll,PrintUIEntry /u /if /b "HP B&W LaserJet 3700 in D26" /f "\\jogdom.local\NETLOGON\InstallPrinters\Drivers\HP LJ 24x0\hpc24x0c.INF" /r "\\JOGSERV01\hp3700n-002BW$" /m "HP LaserJet 2420 PCL 6" /q
    
    rundll32 printui.dll,PrintUIEntry /y /n "HP B&W LaserJet 3700 in D26" /q
    The first 2 commands delete any existing copies of the printers if already installed the second 2 install the correct printers, network path and drivers. The last one sets the default printer name for windows to use.

    Don’t know if that helps as you are using a different type of scripting but for plain old *.BAT scripts this works really well.


  8. #8
    tosh74's Avatar
    Join Date
    Dec 2006
    Location
    Scotland
    Posts
    136
    Thank Post
    27
    Thanked 43 Times in 27 Posts
    Rep Power
    23

    Re: Printer script not running at start up

    Quote Originally Posted by Geoff
    Printer scripts do not run as a Computer startup script. You need to assign the script to the USER startup script
    This may not be sufficient. If the user does not have enough access to the machine to install drivers, the printer will not work. You can get round this by running the printer script at machine start-up though and pre loading the drivers.

    If in doubt, I suggest you run the printer script both at computer start-up and user login. Unless you're overly concerned about machine start-up times of course.
    I could be wrong here but I do not think that logon/startup scripts are run with the users credentials - I think they are run by the System account

  9. #9
    richard
    Guest

    Re: Printer script not running at start up

    I can't tweak the script as its my bosses and he doesn't like me touching things he does and i'm not in work now till thursday but i'll have another look when i'm back

  10. #10
    MicrodigitUK's Avatar
    Join Date
    May 2007
    Location
    Wiltshire
    Posts
    334
    Thank Post
    37
    Thanked 55 Times in 51 Posts
    Rep Power
    24

    Re: Printer script not running at start up

    Quote Originally Posted by richard
    My boss made a new printer script and it works locally but when we tries to deploy it as a startup script it fails to run at all. Its been added as startup script to the relevant OU but no matter what we try it doesn't work. Any ideas?
    I think it might be because the drivers for the printer are not installed on the pc’s you’re deploying the VB scrip to, so it simply doesn’t install the printer and ignores it.

    You also will probably need to defiantly run them as start-up scripts because start-up scripts are run with Admin privileges and logon scripts are run with the logging-on-user privileges.

    p.s. If you try out my *.BAT scripts way of doing it, be warned that parts of the script are case sensitive as I found out the long way after days experimenting. I think its because the driver file printer name/description must be an exact match to find the driver in the *.INF file!!!!


  11. #11

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,804
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Printer script not running at start up

    Quote Originally Posted by tosh74
    I could be wrong here but I do not think that logon/startup scripts are run with the users credentials - I think they are run by the System account
    Yes the login scripts are run with elevated credentials, however if you've altered any of the driver installation group policy settings it'll break. Thus the need to have the script run during computer start-up (as it uses the computers domain account, which also has system level privileges to the local machine).

  12. #12

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124

    Re: Printer script not running at start up

    Pretty sure that's not true.

    machine startup scripts run in the security context of the machine so can do pretty much anything to the machine but may not have access to network resources (if you need a machine script to access files on a server then give domain computers read access to the relevant files)

    user scripts run in the security context of the user - they have no special rights.

    local printers need to be able to install drivers on the machine so can't be installed as a normal user. network printers don't need this - anyone can add a network printer.

    If you're scripting it then using the rundll32 printui.dll,PrintUIEntry type command is effectively installing a local printer - it could run as a machine startup script but won't run as a user logon script.

    Scripts running using the vbscript WshNetwork.AddWindowsPrinterConnection type command add network printers and can be run by ordinary users - that's why it's ideal for a login script (but useless as a machine startup script because you'll end up mapping a printer which is only available for the computer account!)

    If you've written a vbscript login or startup script then use a debugger to step through it to see what it's actually doing. Any version of Visual Studio will do this or you can download the Microsoft Script Debugger (google it - the URL is too long!) You then run the script with //x at the end and it runs through the debugger.

SHARE:
+ Post New Thread

Similar Threads

  1. A Printer Script
    By Ric_ in forum Scripts
    Replies: 164
    Last Post: 1st October 2010, 10:11 AM
  2. Script to sort by name on start menu
    By FN-GM in forum Scripts
    Replies: 21
    Last Post: 17th October 2007, 05:33 PM
  3. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM
  4. VBS Drive script is running from
    By Samson in forum Scripts
    Replies: 5
    Last Post: 10th May 2007, 03:29 PM
  5. Start Menu Script Problem
    By phillipmillward in forum Windows
    Replies: 4
    Last Post: 23rd November 2006, 08:50 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
  •