Page 1 of 1 1
Topic Options
#112155 - 2004-01-20 11:20 PM Adding Network Printer?
cwhitmore Offline
Starting to like KiXtart

Registered: 2001-05-23
Posts: 102
Loc: Austin, Texas, USA
I started working on this a few months ago, but had to drop it. Now I'M BACK!!!
I want to setup a script that checks to see if a user is already setup on a printer, if not add that printer.
I tried using ADDPRINTERCONNECTION with the following command:
If ADDPRINTERCONNECTION ("\\server\HP4000N-IT") = 0
net use lpt1: \\oak2000\HP4000N-IT
EndIf
There is a Net2Fax that installs by default to LPT1, but that can be mapped over.
I did a search on other posts and someone suggested using the ADDPRINTER UDF. Can someone send me a link on how to use UDF's?
thanks,
Carlton.

Top
#112156 - 2004-01-20 11:34 PM Re: Adding Network Printer?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Why don't you go to the FAQ Forum and read the post "How to use UDF's"? There are also other printer-related UDFs in the UDF forum.
_________________________
There are two types of vessels, submarines and targets.

Top
#112157 - 2004-01-20 11:51 PM Re: Adding Network Printer?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
you don't need to have any udf as ADDPRINTERconnection() does ADD the PRINTER.
if you only want to check the map state of printer, look at www.kixhelp.com/udfs for primapstate()
_________________________
!

download KiXnet

Top
#112158 - 2004-01-21 12:38 AM Re: Adding Network Printer?
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2082
Loc: Tulsa, OK
The first problem I see is that you are using 'net use' which is not a Kix command. You should use the 'use' command like so...

Code:
use lpt1: '\\oak2000\HP4000N-IT'


Top
#112159 - 2004-01-21 02:54 AM Re: Adding Network Printer?
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: Lincoln, NE
Check out this thread and search boards for ADDPRINTERCONNECTION

http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=110107&page=0&view=collapsed&sb=5&o=&fpart=1

From what you're asking, you just want a simple script for each group? for one printer to be added? If so, create a group of users for each printer and add users to this printer group.

(My Script uses computer group membership using Function ComputerInGroup.udf, not user groups, so you'd need to modify the script that you'll find in the thread I posted above for users, not computers. Or try the simple script I posted here.)

This script has not been tested for syntax.

Code:

;****adds and sets default printer if printer does not exist
if InGroup('your_group_name')

$printer=('\\server\printershare')

if not PriMapState($printer)
$nul=AddPrinterConnection($printer)
endif

endif

;FUNCTION PriMapState v1.1
;
;AUTHOR Lonkero (Jooel.Nieminen@gwspikval.com)
;
;ACTION Checks for existent networkprinter connection
;
;SYNTAX PriMapState(PRINTER)
;
;PARAMETERS PRINTER
; Printers name to be checked
;
;RETURNS 1 if printer connected
; 2 if printer is default
; nothing if not connected
;
;REMARKS code for w9x adapted from BrianTX
;
;DEPENDENCIES none
;
;EXAMPLE if not PriMapState('\\server\printer1')
; "printer not connected!"
; end
;
function PriMapState($_Pri)
if @inwin=1
if len(readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices",$_Pri))
if split(readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0]=$_Pri
$PriMapState=2
else
$PriMapState=1
endif
endif
else
dim $_Root,$_C,$_C2 $_Root="HKLM\System\CurrentControlSet\control\Print\Printers"
for $_C=0 to 259
$_C2=enumkey($_Root,$_C)
If instr(READVALUE($_Root+"\"+$_C2,"Port"),$_Pri)
If instr(READPROFILESTRING("%windir%\win.ini","windows","device"),$_Pri)
$PriMapState = 2
Else
$PriMapState = 1
Endif
Endif
if $_C2=259 $_C=$_C2 endif
next
endif
endfunction





Edited by tjcarst (2004-01-21 02:56 AM)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 158 anonymous users online.
Newest Members
Jodey, Hiker, GTRoberts, KatieQuinn, Brennnnn
17684 Registered Users

Generated in 0.031 seconds in which 0.012 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org