#169117 - 2006-10-09 11:00 PM
Install IP Printers as Admin
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
Background: I am using MS VB script to install ip printers via KIX. I call this *.vbs file from a BAT file within KIX and it works fine, but it requires the user to have admin's rights on local computer in order for it to work.
Question: Is there a way that you can have KIX or VB installs IP printer as 'admin'? Our user profiles do not have sufficient rights on our domain to install printers, so the only way that I know of is to have individual accounts set as "administrator" on local computer...
Current script as followed.
strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_ objNewPort.Name = "IP_192.168.24.37" objNewPort.Protocol = 1 objNewPort.HostAddress = "192.168.24.37" objNewPort.PortNumber = "9100" objNewPort.SNMPEnabled = False objNewPort.Put_
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = "Xerox 4505 PS" objPrinter.PortName = "IP_192.168.24.37" objPrinter.DeviceID = "2FLX4500PS" objPrinter.Location = "Mission Valley Admin" objPrinter.Network = "True" 'objPrinter.Shared = "True" 'objPrinter.ShareName = "Test" objPrinter.Put_
If someone knows VB, please help. Any input is greatly appreciated. Thanks. Hieu
|
|
Top
|
|
|
|
#169119 - 2006-10-09 11:13 PM
Re: Install IP Printers as Admin
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
Yes, I do have a Win2000/2K3 domain. Installing SHARED printers from the print server is not a problem, but installing IP printer for local printing requires users to have admin rights on local PCs. I am hoping that someone with VB exprience can help out with the existing script..
My network situation is a bit unique...locally, they'd like to print to printers via IP, bypassing the print server over the WAN. When printing documents via Citrix, then it'll print through the shared printers on print server.
Thanks for your help. Hieu
|
|
Top
|
|
|
|
#169122 - 2006-10-10 12:00 AM
Re: Install IP Printers as Admin
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
Witto / Jooel - Thank you for your responses. My remote branch has less than 10 computers and no local servers. All domain authentication is done via the WAN back to our central office. The above script will work in the login script if the user has appropriate rights. I was thinking of using a generic username with appropriate rights to install printers from the login script so that I don't have to manually installed the IP printers for that location....if that's possible at all.
|
|
Top
|
|
|
|
#169125 - 2006-10-10 07:59 PM
Re: Install IP Printers as Admin
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
Witto / Jooel - Actually, I've 20 remote locations, and that's why I am looking to automate things. Sure, I can install the printers manually for them, but that'll be the last option though. The existing script works fine..I just need to address the rights issue..
Thank you both for your suggestion. Hieu
|
|
Top
|
|
|
|
#169127 - 2006-10-12 06:52 PM
Re: Install IP Printers as Admin
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
I used "reg add" command and TID 314486 from Microsoft and that takes care of what I need.
Thanks, Witto for all of your input. Hieu
|
|
Top
|
|
|
|
#169129 - 2006-10-13 06:51 PM
Re: Install IP Printers as Admin
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
Allen -
We've only 5-6 workstations at remote branches, and we're making changes one branch at a time. We only need to change one laser printer at each remote branch, so this script might not be the most efficient way to installing IP printers, but it'll work. Then, we modified the KIX login script to add the same printer that's shared on the print server when they log into Citrix.
CLS
if not @TSSESSION $ComputerName = SUBSTR(@wksta, 1, 3) Addprinterconnection("\\servername\shared_label_printer1") Addprinterconnection("\\servername\shared_label_printer2") Use I: "\\servername\%username%" Use Q: "\\servername\shared_folder" else $ComputerName = SUBSTR(%CLIENTNAME%, 1,3) Addprinterconnection("\\servername\shared_laser_printer") Addprinterconnection("\\servername\shared_label_printer1") Addprinterconnection("\\servername\shared_label_printer2") SetDefaultPrinter ("\\servername\shared_laser_printer")= 0 endif
Here's the sample printer script that we tested:
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v Protocol /t REG_DWORD /d 0x1
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v Version /t REG_DWORD /d 0x1
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v HostName /t REG_SZ /d ""
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v IPAddress /t REG_SZ /d "192.168.24.37"
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v HWAddress /t REG_SZ /d ""
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v PortNumber /t REG_DWORD /d 0x238c
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v "SNMP Community" /t REG_SZ /d "public"
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v "SNMP Enabled" /t REG_DWORD /d 0x1
reg add "\\TOMCAT01\HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\TestXPort" /v "SNMP Index" /t REG_DWORD /d 0x1
psservice \\TOMCAT01 stop spooler (utility from www.sysinternals.com)
psservice \\TOMCAT01 start spooler (utility from www.sysinternals.com)
sleep 15 (utility from Win2K Resource Kit) - may need to increase wait time if going over slow WAN link to allow REG ADD to complete and spooler serivce restarted.
rundll32 printui.dll,PrintUIEntry /if /b "Test Printer" /c\\TOMCAT01 /f \\NEWFOCUS\4500\x4500CL6.inf /r "TestXPort" /m "Xerox Phaser 4500N PCL6"
|
|
Top
|
|
|
|
#169132 - 2006-10-13 07:08 PM
Re: Install IP Printers as Admin
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
The IP printer did get installed locally through the printer.bat file as shown above..it's not running via Kix.
I wasn't sure of whether "net stop/start" would be able to restart service on a remote computer, so PsService works out great.
|
|
Top
|
|
|
|
#169134 - 2006-10-14 02:42 AM
Re: Install IP Printers as Admin
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4567
Loc: USA
|
I guess I don't see how this helps get around needing admin permissions to install the printer. Care to elaborate?
By the way, the AddPrinter() UDF does pretty much what you are doing here, but it too needs admin privs.
[edit: Are you running the reg edit code as an admin script? If yes, I understand now.... ]
Edited by Allen (2006-10-14 02:46 AM)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 302 anonymous users online.
|
|
|