Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Re: Batch file - add network printers via printui.dll, PrintUIEntry

Reply
Thread Tools Display Modes

Re: Batch file - add network printers via printui.dll, PrintUIEntry

 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      07-29-2008

"aroy" <> wrote in message
news:5518af76-da58-4afe-a44d-...
> Greetings all,
>
> I have a client who chooses to deploy printers via their login script.
> For each of the ~30 printers I have a batch file containing:
>
> :: Setting the default printer
> rundll32 printui.dll,PrintUIEntry /in /n "\\server_name
> \printer_name01"
> rundll32 printui.dll,PrintUIEntry /y /n "\\server_name\priner_name01"
>
> :: Setting the alternate printer
> rundll32 printui.dll,PrintUIEntry /in /n "\\server_name
> \printer_name02"
>
> Users access is to these files is controlled by using ifmember.exe. If
> user is a member of printer_group03 then run this batch file else move
> on to next.
>
> This works fine.
>
> BUT, each time they login this scrip it run. How can I first check to
> see if a specific printer is installed before adding it?
>
> Essentially what I want to do is:
>
> If exist(on local computer, NOT server) \\server_name\printer_name01
> goto exit
> if NOT exist \\server_name\printer_name01 add it
>
> Is that at all possible??
>
> thanks.


Have a look at this help command: rundll32 printui.dll,PrintUIEntry /?


 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      07-29-2008

"aroy" <> wrote in message
news:60a801cf-bc6e-43d3-b6e8-...
On Jul 28, 10:37 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> "aroy" <aaronm...@gmail.com> wrote in message
>
> news:5518af76-da58-4afe-a44d-...
>
>
>
> > Greetings all,

>
> > I have a client who chooses to deploy printers via their login script.
> > For each of the ~30 printers I have a batch file containing:

>
> > :: Setting the default printer
> > rundll32 printui.dll,PrintUIEntry /in /n "\\server_name
> > \printer_name01"
> > rundll32 printui.dll,PrintUIEntry /y /n "\\server_name\priner_name01"

>
> > :: Setting the alternate printer
> > rundll32 printui.dll,PrintUIEntry /in /n "\\server_name
> > \printer_name02"

>
> > Users access is to these files is controlled by using ifmember.exe. If
> > user is a member of printer_group03 then run this batch file else move
> > on to next.

>
> > This works fine.

>
> > BUT, each time they login this scrip it run. How can I first check to
> > see if a specific printer is installed before adding it?

>
> > Essentially what I want to do is:

>
> > If exist(on local computer, NOT server) \\server_name\printer_name01
> > goto exit
> > if NOT exist \\server_name\printer_name01 add it

>
> > Is that at all possible??

>
> > thanks.

>
> Have a look at this help command: rundll32 printui.dll,PrintUIEntry /?


Thanks, best I can find in there is a /q. That hides the little dialog
box that pops up when the printer is added. That gets the job
done...sort of. The users are not bothered by the dialog box but, the
printers are still being installed each time they login regardless of
whether or not they are already installed.

I would still like to be able to check if the printer is installed on
the local machine first.

thanks,
===========
You could use the script below but your users might not
appreciate the delay it introduces into the logon process.
Invoking it remotely and creating a local tell-tale file would
get around the delay.
Set objWMI = GetObject("winmgmts:\\.\root\CIMV2")
Set colPrn = objWMI.ExecQuery("SELECT * FROM Win32_Printer")

For Each objItem In colPrn
WScript.Echo "Printer name: " & objItem.name & VbCrLf & _
"====================================" & VbCrLf & _
"Port Name: " & objItem.PortName & VbCrLf & _
"Printer State: " & objItem.PrinterState & VbCrLf & _
"Printer Status: " & objItem.PrinterStatus & VbCrLf & _
"PrintJobDataType: " & objItem.PrintJobDataType & VbCrLf & _
"Print Processor: " & objItem.PrintProcessor & VbCrLf & _
"Spool Enabled: " & objItem.SpoolEnabled & VbCrLf & _
"Separator File: " & objItem.SeparatorFile & VbCrLf & _
"Status: " & objItem.Status & VbCrLf & _
"StatusInfo: " & objItem.StatusInfo & VbCrLf & _
"ShareName: " & objItem.ShareName & VbCrLf & _
"Horizontal Res: " & objItem.HorizontalResolution & VbCrLf & _
"Vertical Res: " & objItem.VerticalResolution
WScript.Echo "Work Offline: " & objItem.WorkOffline
Next


 
Reply With Quote
 
JFord
Guest
Posts: n/a

 
      07-30-2008
A bit faster than WMI is the REG command...

:\>REG QUERY "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices" |
FIND /I "Printer Name"

based on %errorlevel% you can end or add

-J

"Pegasus (MVP)" wrote:

>
> "aroy" <> wrote in message
> news:60a801cf-bc6e-43d3-b6e8-...
> On Jul 28, 10:37 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> > "aroy" <aaronm...@gmail.com> wrote in message
> >
> > news:5518af76-da58-4afe-a44d-...
> >
> >
> >
> > > Greetings all,

> >
> > > I have a client who chooses to deploy printers via their login script.
> > > For each of the ~30 printers I have a batch file containing:

> >
> > > :: Setting the default printer
> > > rundll32 printui.dll,PrintUIEntry /in /n "\\server_name
> > > \printer_name01"
> > > rundll32 printui.dll,PrintUIEntry /y /n "\\server_name\priner_name01"

> >
> > > :: Setting the alternate printer
> > > rundll32 printui.dll,PrintUIEntry /in /n "\\server_name
> > > \printer_name02"

> >
> > > Users access is to these files is controlled by using ifmember.exe. If
> > > user is a member of printer_group03 then run this batch file else move
> > > on to next.

> >
> > > This works fine.

> >
> > > BUT, each time they login this scrip it run. How can I first check to
> > > see if a specific printer is installed before adding it?

> >
> > > Essentially what I want to do is:

> >
> > > If exist(on local computer, NOT server) \\server_name\printer_name01
> > > goto exit
> > > if NOT exist \\server_name\printer_name01 add it

> >
> > > Is that at all possible??

> >
> > > thanks.

> >
> > Have a look at this help command: rundll32 printui.dll,PrintUIEntry /?

>
> Thanks, best I can find in there is a /q. That hides the little dialog
> box that pops up when the printer is added. That gets the job
> done...sort of. The users are not bothered by the dialog box but, the
> printers are still being installed each time they login regardless of
> whether or not they are already installed.
>
> I would still like to be able to check if the printer is installed on
> the local machine first.
>
> thanks,
> ===========
> You could use the script below but your users might not
> appreciate the delay it introduces into the logon process.
> Invoking it remotely and creating a local tell-tale file would
> get around the delay.
> Set objWMI = GetObject("winmgmts:\\.\root\CIMV2")
> Set colPrn = objWMI.ExecQuery("SELECT * FROM Win32_Printer")
>
> For Each objItem In colPrn
> WScript.Echo "Printer name: " & objItem.name & VbCrLf & _
> "====================================" & VbCrLf & _
> "Port Name: " & objItem.PortName & VbCrLf & _
> "Printer State: " & objItem.PrinterState & VbCrLf & _
> "Printer Status: " & objItem.PrinterStatus & VbCrLf & _
> "PrintJobDataType: " & objItem.PrintJobDataType & VbCrLf & _
> "Print Processor: " & objItem.PrintProcessor & VbCrLf & _
> "Spool Enabled: " & objItem.SpoolEnabled & VbCrLf & _
> "Separator File: " & objItem.SeparatorFile & VbCrLf & _
> "Status: " & objItem.Status & VbCrLf & _
> "StatusInfo: " & objItem.StatusInfo & VbCrLf & _
> "ShareName: " & objItem.ShareName & VbCrLf & _
> "Horizontal Res: " & objItem.HorizontalResolution & VbCrLf & _
> "Vertical Res: " & objItem.VerticalResolution
> WScript.Echo "Work Offline: " & objItem.WorkOffline
> Next
>
>
>

 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      07-30-2008

"JFord" <> wrote in message
news:7B2FE55F-B7CD-47C4-A940-...
>A bit faster than WMI is the REG command...
>
> :\>REG QUERY "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices" |
> FIND /I "Printer Name"


The reg.exe command is not a bit faster than WMI, it
is always a lot faster!


 
Reply With Quote
 
J Ford
Guest
Posts: n/a

 
      07-30-2008
True! A definite understatement on my part...

"Pegasus (MVP)" wrote:

>
> "JFord" <> wrote in message
> news:7B2FE55F-B7CD-47C4-A940-...
> >A bit faster than WMI is the REG command...
> >
> > :\>REG QUERY "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices" |
> > FIND /I "Printer Name"

>
> The reg.exe command is not a bit faster than WMI, it
> is always a lot faster!
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Task Scheduler job Hangs (rundll32 printui.dll,PrintUIEntry) Larry Bird Windows Server 3 10-05-2007 01:34 PM
Installing a Network Printer with PrintUI.dll Cam Windows Vista Printing / Faxing / Scanning 0 10-16-2006 09:48 PM
rundll32 printui.dll,PrintUIEntry Question Mario Windows Vista Drivers 3 05-27-2005 01:32 PM
printui.dll,PrintUIEntry internals... Rajneesh Sehgal Windows Vista Drivers 4 04-11-2005 03:13 PM
Printui.dll and setting up printers Aaron Windows Server 1 02-15-2005 09:53 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59