Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
The idea is to run this script from the desktop of the host system and access the client/remote system and make the changes.
I wrote code to map a drive using the local admin id and password. Once I do that I'm able to stop and start services and add and delete files from the host system, but I can't seem to find the code that will allow me to add the TCP/IP port to the client/remote system. Any help would be grateful.
Here is a example of the VBS Script I spruced up. I created a winbatch script to map a drive to a client system using the local administrator id and password. Then I added a runwait specifying this vbs script. The script does not add the TCP/IP port or printer on the client system, but adds it to the host system where the script ran. I need something that I can run from the host to modify the client.
******************************************************************* Command to place in the Start/Run box: 'wscript "dirve:\Subdirectory\AddPrinter.vbs" "192.168.0.230" "HP LaserJet 8100 Series PCL" ******************************************************************* Dim ArgObj, PrinterIP, PrinterName Set ArgObj = WScript.Arguments PrinterIP = ArgObj(0) PrinterName = ArgObj(1) if PrinterName = "HP8100" Then PrinterName = "HP LaserJet 8100 Series PCL" 'msgbox "Variable 1=" & var1 & " Variable 2=" & var2 set ArgObj = Nothing 'Clear object out of memory '******** Register prnadmin.dll file on client computer ******* Set WshShell = Wscript.CreateObject("Wscript.Shell") WshShell.Run "regsvr32 /s \\fl-msitest-orl\nde\Prnadmin.dll",1,TRUE '************** Create the port first ***************************** 'Port types const kTcpRaw = 1, kTcpLPr = 2, kLocal = 3, kLocalDownLevel = 4, kLprMon = 5, kHPdlc = 7 dim oPort dim oMaster set oPort = CreateObject("Port.Port.1") set oMaster = CreateObject("PrintMaster.PrintMaster.1") oPort.PortName = "IP_" & PrinterIP oPort.PortType = kTcpRaw oPort.HostAddress = PrinterIP 'oPort.PortNumber = "9100" oMaster.PortAdd oPort if Err <> 0 then msgbox "There was an error creating the port." end if '************** Create the printer second ********************** 'Change MyPrinter to the name of the printer that you are adding. 'Change PrinterDriver to the name of the printer driver that you are adding. dim oPrinter set oPrinter = CreateObject("Printer.Printer.1") oPrinter.PrinterName = PrinterName ' name of the printer as it appears in the Printers folder oPrinter.DriverName = PrinterName ' name that is referenced in ntprint.inf oPrinter.PortName = "IP_" & PrinterIP ' Specify a port name. Can also point to LPT or COM port. oMaster.PrinterAdd oPrinter If Err <> 0 then msgbox "There was an error creating the printer." end if '******************************************************************* set ArgObj = Nothing msgbox "The script is finished."
Note: This code could probably be translated to WinBatch.
To configure a standard TCP/IP printer port on a remote system:
cscript c:\winnt\system32\prnport.vbs -t -r PortName [-s RemoteComputer] [-o {raw -n PortNumber | lpr}] [-h IPAddress] [-q QueueName] [-m{e | d}] [-i IndexName] [-y CommunityName] [-2{e | d}] [-u UserName -w Password]example:
cscript c:\winnt\system32\prnport.vbs -t -r IP_192.168.0.150 -s computername -o raw -n 9100 -h 192.168.0.150 -md -2d -u Administrator -w passwordTo add a printer on a remote system:
cscript c:\winnt\system32\prnmngr.vbs -a -p PrinterName [-s RemoteComputer] -m DriverName -r PortName [-u UserName -w Password]example:
cscript c:\winnt\system32\prnmngr.vbs -a -p "I Added This Printer" -s computername -m "HP LaserJet 8100 Series PCL" -r IP_192.168.0.150 -u Administrator -w password
Article ID: W16659
File Created: 2005:02:18:12:21:46
Last Updated: 2005:02:18:12:21:46