Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


printer install once only

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,62105
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> printer install once only
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 printer install once only - 7/2/2008 12:09:54 AM   
  aschwartz

 

Posts: 12
Score: 0
Joined: 4/30/2008
Status: offline
So we are looking to add a line to our login script that will add a printer driver and create a printer:
 
rundll32 printui.dll,PrintUIEntry /if /b  "Q Drive" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "HP LaserJet 8000 Series PS" /z

When you run this, it creates a printer using the HP LJ 8000 driver called the Q drive.  It is used for doing a print to file to create a pdf.
It works, I tried it, so I know I can script it too. 

My only problem, and being a newbie at scripting, is that I figure I only want it to run once, so I figure I could create a section in the lo9gin script just for this, and have it check for a file that I can create on the local C: drive and then if it exists not to run that portion, but if it doesnt, then to run the above line, and then create the file, so that it doesnt run again.

Is this easily accomplished, or would it be easier to just check for the existance of the printer itself, and if it is there then to exit the script.  I am unsure of how to proceed.  Thanks in advance.
 
 
Post #: 1
 
 RE: printer install once only - 7/2/2008 12:24:10 AM   
  dm_4ever


Posts: 2414
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
Search for these....

WScript.Network and EnumPrinterConnections method
InStr() Function

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aschwartz)
 
 
Post #: 2
 
 RE: printer install once only - 7/2/2008 1:23:44 AM   
  aschwartz

 

Posts: 12
Score: 0
Joined: 4/30/2008
Status: offline
Thanks, but the enum printer search brought me 2 results, this post and another that wasnt related, at least that I could see.

I have the printer install piece via that one rundll line.  I dont know another way, nor do I have time to figure out another way to do it since this works.  I was looking for an assist with the only run once piece.  Thanks anyway.

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: printer install once only - 7/2/2008 2:24:42 AM   
  Rischip


Posts: 468
Score: 2
Joined: 3/26/2007
Status: offline
http://msdn.microsoft.com/en-us/library/zhds6k80(VS.85).aspx

adapt this to look for your Q Drive printer and exit the sub before installing if it exists.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to aschwartz)
 
 
Post #: 4
 
 RE: printer install once only - 7/2/2008 4:18:11 AM   
  aschwartz

 

Posts: 12
Score: 0
Joined: 4/30/2008
Status: offline
I guess my disclaimer about being a newbie was missed.

Thanks for the link, but I have no idea what that would do, nor how to adapt it to what I was looking for.
Is that even VB?  I cant understand it.

Thanks again for the assist, I guess I am too basic to begin to understand that.  No worries.

Is this the best way to go, or would be just creating a text file at the root of C: and checking for it be sufficient?  Or is the suggested method here the best practice for doing this type of thing?

< Message edited by aschwartz -- 7/2/2008 4:22:47 AM >

(in reply to Rischip)
 
 
Post #: 5
 
 RE: printer install once only - 7/2/2008 4:27:28 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Using EnumPrinterConnections would be a more scaleable solution. No what is linked is not VB. It is VBScript which is what this forum is here to help you write.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aschwartz)
 
 
Post #: 6
 
 RE: printer install once only - 7/2/2008 7:24:41 AM   
  aschwartz

 

Posts: 12
Score: 0
Joined: 4/30/2008
Status: offline
I understand that, I just meant that that link to that info made no sense to me or how I could use it.

I assume that checking for the printer existance would be the first step, and if it exists, then to cancel that portion of the script, but what I am not aware of is how to do it.  Not that I am asking someone to do it for me, I just figured someone else had done something similar, and they might have simple code they could post

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: printer install once only - 7/2/2008 7:49:03 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
This is about as simple as the code gets:

        Set WshNetwork = WScript.CreateObject("WScript.Network")
        Set oDrives = WshNetwork.EnumNetworkDrives
        Set oPrinters = WshNetwork.EnumPrinterConnections
        WScript.Echo "Network drive mappings:"
        For i = 0 to oDrives.Count - 1 Step 2
           WScript.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
        Next
        WScript.Echo
        WScript.Echo "Network printer mappings:"
        For i = 0 to oPrinters.Count - 1 Step 2
           WScript.Echo "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1)
        Next

run it. See what it does. Understand what it does. Try to change it to meet your need. Post back here when you run into problems.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aschwartz)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> printer install once only Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts