Add Printer .bat

May 28th, 2009 by shiraj

If RUNDLL32 just won’t do the job:

Sometimes we need to do just alittle more than RUNDLL32 is capable of, like installing a TCP/IP printer port.
In that case, consider buying yourself a copy of the Windows 2000 Server/Windows Server 2003 Resource Kit and use PRNADMIN.DLL and the accompanying sample scripts written in VBScript.

My own AddIPPrn.bat below uses these VBScripts to install a printer, its driver and a TCP/IP printer port on a remote computer


@ECHO OFF
:: Check Windows version
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
SETLOCAL

:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
::                                                                         ::
::    Modify the following lines; no quotes for PrnShort and PortIP!       ::
::                                                                         ::
::    The values for PrnType and TargetOS can be found in the INF file     ::
::    that comes with the (extracted) printer driver.                      ::
::                                                                         ::
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::

SET PrnName="Accounting 2nd Floor"
SET PrnShort=Accounting2
SET PrnType="Kyocera Mita FS-3820N"
SET DrvPath="\\server\share\Drivers\Kyocera\FS-3820N\W2K"
SET InfPath="\\server\share\Drivers\Kyocera\FS-3820N\W2K\oemsetup.inf"
SET PortIP=112.113.114.115
SET TargetOS="Windows 2000"

:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
::                                                                         ::
::       End of adjustments                                                ::
::                                                                         ::
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::

:: Check command line arguments
IF "%~1"=="" GOTO Syntax
SET PC=%~1
ECHO."%PC%" | FINDSTR.EXE /R /C:"[?/]" >NUL && GOTO Syntax
PING.EXE %PC% 2>NUL | FIND.EXE  "TTL=" >NUL || (
	ECHO Computer %PC% is unavailable
	ECHO.
	GOTO Syntax
)

:: Check if the required VBScripts are available in the current directory
SET Error=0
FOR %%A IN (prncfg prnmgr drvmgr portmgr) DO IF NOT EXIST %%A.vbs SET Error=1
IF "%Error%"=="1" GOTO Syntax

:: Check if the printer was installed already
CSCRIPT.EXE //NoLogo prnmgr.vbs -l -c \\%PC% | FIND.EXE /I "%PrnShort%" >NUL && (
	ECHO A printer named %PrnShort% already exists on %PC%
	ECHO.
	GOTO Syntax
)

:: Check if the printer port was installed already
CSCRIPT.EXE //NoLogo portmgr.vbs -l -c \\%PC% | FINDSTR.EXE /E /I "IP_%PortIP%" >NUL && (
	ECHO TCP/IP printer port %PortIP% already exists on %PC%
	ECHO.
	GOTO Syntax
)

:: Prompt the user, and allow him/her to abort the installation
ECHO You are about to add a local printer %PrnShort% on computer %PC%
ECHO.
PAUSE

:: Install the driver
CSCRIPT.EXE //NoLogo drvmgr.vbs  -a -c \\%PC% -p %DrvPath% -i %InfPath% -v %TargetOS% -m %PrnType% -t Intel
:: Install the local IP print port, type raw, SNMP disabled
CSCRIPT.EXE //NoLogo portmgr.vbs -a -c \\%PC% -p IP_%PortIP% -h %PortIP% -t raw -n 9100 -md
:: Install the local printer with the driver and port we just installed
CSCRIPT.EXE //NoLogo prnmgr.vbs  -a -c \\%PC% -b %PrnName% -m %PrnType% -r IP_%PortIP%
:: Configure the local printer as not shared and not published in Active Directory
CSCRIPT.EXE //NoLogo prncfg.vbs  -s -b \\%PC%\%PrnShort% -published -shared

:: Display or log the configuration of the new printer
IF /I "%~2"=="/L" (SET Log="%PrnShort%_%PC%.log") ELSE (SET Log=CON)
(
	CSCRIPT.EXE //NoLogo drvmgr.vbs  -l -c \\%PC%
	CSCRIPT.EXE //NoLogo portmgr.vbs -l -c \\%PC%
	CSCRIPT.EXE //NoLogo prnmgr.vbs  -l -c \\%PC%
	CSCRIPT.EXE //NoLogo prncfg.vbs  -g -b \\%PC%\%PrnShort%
) > %Log% 2>&1

:: Done
GOTO End

:Syntax
ECHO.
ECHO AddIPPrn.bat,  Version 1.01 for Windows 2000 with Server Resource Kit
ECHO Install a (hard coded) local IP printer %PrnShort% on a remote computer
ECHO.
ECHO Usage:  ADDIPPRN.BAT   computername  [ /L ]
ECHO.
ECHO Where:  "computername" is the computer on which the printer should be installed
ECHO         "/L"           logs the results in {printername}_{computername}.log
ECHO                        (default is display on screen)
ECHO.
ECHO Notes:  [1] You need to modify the first couple of lines from this batch file
ECHO             to install your own printer, port and driver. You may then want
ECHO             to save the modified batch file as {printername}.bat.
ECHO         [2] This batch file requires drvmgr.vbs, portmgr.vbs, prnmgr.vbs and
ECHO             prncfg.vbs from the Windows 2000/2003 Server Resource Kit; these
ECHO             scripts must all be located in the current directory.
ECHO         [3] These VBScripts require PRNADMIN.DLL from the Resource Kit to be
ECHO             installed on the computer that runs the scripts.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com

:End
IF "%OS%"=="Windows_NT" ENDLOCAL

If all you need is to backup/restore, clone or migrate existing printers:

May 28th, 2009 by shiraj

Often the printer configurations of existing computers need to be cloned to other computers, or restored after reinstalling Windows.
In those cases, a backup/export and restore/import with Microsoft’s PrintMig 3.1 may be the best (and easiest) solution.
Though earlier versions of PrintMig were GUI only, version 3.1 can also be run without user interaction from the command line or in a batch file:

Microsoft (R) Windows (TM) Printer Migrator 3.1
Copyright (C) 1997-2002 Microsoft Corp. All rights reserved

usage: PRINTMIG [options] [server]
       [-?] Display this message
       [-b] Backup - followed by CAB file name
       [-r] Restore - followed by CAB file name
       [-l] Attempt to convert LPR Ports to SPM
       [-i] Suppress warning popups.  Info still written to log file.

If server is not specified then the local machine is implied.

Example command line to restore an existing config to a server:
  printmig -r d:\print\ps1.cab \\prt-srvr1

Example command line to backup a server to the specified file:
  printmig -b "\\filesrv\store\print server 2.cab" \\prt-srvr2

Scripting Printer in Windows

May 28th, 2009 by shiraj

in command prompt type: rundll32 printui.dll,PrintUIEntry /?

i.e C:\Documents and Settings\Administrator>rundll32 printui.dll,PrintUIEntry /?

this will show all the usable parameters, as below. PrintUI is the command to search. can be used on batch file and in login script.

Usage: rundll32 printui.dll,PrintUIEntry [options] [@commandfile]
/a[file] binary file name
/b[name] base printer name
/c[name] unc machine name if the action is on a remote machine
/dl delete local printer
/dn delete network printer connection
/dd delete printer driver
/e display printing preferences
/f[file] either inf file or output file
/ga add per machine printer connections
/ge enum per machine printer connections
/gd delete per machine printer connections
/h[arch] driver architecture one of the following, Alpha | Intel | IA64 | x64
/ia install printer driver using inf file
/id install printer driver using add printer driver wizard
/if install printer using inf file
/ii install printer using add printer wizard with an inf file
/il install printer using add printer wizard
/in add network printer connection
/j[provider] print provider name
/k print test page to specified printer, cannot be combined with command when installing a printer
/l[path] printer driver source path
/m[model] printer driver model name
/n[name] printer name
/o display printer queue view
/p display printer properties
/q quiet mode, do not display error messages
/r[port] port name
/s display server properties
/Ss Store printer settings into a file
/Sr Restore printer settings from a file
Store or restore printer settings option flags that must be placed at the end of command:
2    PRINTER_INFO_2
7    PRINTER_INFO_7
c    Color Profile
d    PrinterData
s    Security descriptor
g    Global DevMode
m    Minimal settings
u    User DevMode
r    Resolve name conflicts
f    Force name
p    Resolve port
/u use the existing printer driver if it’s already installed
/t[#] zero based index page to start on
/v[version] driver version one of the following, Windows 95, 98 and Me | Windows NT 4.0 | Windows NT 4.0 or 2000 | Windows 2000 or XP | Windows XP
/w prompt the user for a driver if specified driver is not found in the inf
/y set printer as the default
/Xg get printer settings
/Xs set printer settings
/z do not auto share this printer
/Y do not auto generate a printer name
/K changes the meaning of /v and /h to accept 0,1,2,3, respectively for Windows x64 and Windows IA64 | Windows NT x86 | Windows NT Alpha_AXP | Windows 4.0
/Z share this printer, can only be used with the /if option
/? help this message
@[file] command line argument file
/Mw[message] show a warning message before committing the command
/Mq[message] show a confirmation message before committing the command
/W[flags] specifies flags and switches for the wizards (for APW & APDW)
r    make the wizards to be restart-able from the last page
/G[flags] specifies global flags and switches
w    suppress setup driver warnings UI (super quiet mode)

Examples:
Run server properties:
rundll32 printui.dll,PrintUIEntry /s /t1 /n\\machine
Run printer properties:
rundll32 printui.dll,PrintUIEntry /p /n\\machine\printer
Run add printer wizard localy:
rundll32 printui.dll,PrintUIEntry /il
Run add printer wizard on \\machine:
rundll32 printui.dll,PrintUIEntry /il /c\\machine
Run queue view:
rundll32 printui.dll,PrintUIEntry /o /n\\machine\printer
Run inf install:
rundll32 printui.dll,PrintUIEntry /if /b “Test Printer” /f %windir%\inf\ntprint.inf /r “lpt1:” /m “AGFA-AccuSet v52.3″
Run add printer wizard using inf:
rundll32 printui.dll,PrintUIEntry /ii /f %windir%\inf\ntprint.inf
Add per machine printer connection:
rundll32 printui.dll,PrintUIEntry /ga /c\\machine /n\\machine\printer /j”LanMan Print Services”
Delete per machine printer connection:
rundll32 printui.dll,PrintUIEntry /gd /c\\machine /n\\machine\printer
Enumerate per machine printer connections:
rundll32 printui.dll,PrintUIEntry /ge /c\\machine
Add printer driver using inf:
rundll32 printui.dll,PrintUIEntry /ia /c\\machine /m “AGFA-AccuSet v52.3″ /h “Intel” /v “Windows 2000 or XP” /f %windir%\inf\ntprint.inf
Add printer driver using inf:
rundll32 printui.dll,PrintUIEntry /ia /K /c\\machine /m “AGFA-AccuSet v52.3″ /h “Windows NT x86″ /v 3
Remove printer driver:
rundll32 printui.dll,PrintUIEntry /dd /c\\machine /m “AGFA-AccuSet v52.3″ /h “Intel” /v “Windows 2000 or XP”
Remove printer driver:
rundll32 printui.dll,PrintUIEntry /dd /K /c\\machine /m “AGFA-AccuSet v52.3″ /h “Windows NT x86″ /v 3
Set printer as default:
rundll32 printui.dll,PrintUIEntry /y /n “printer”
Set printer comment:
rundll32 printui.dll,PrintUIEntry /Xs /n “printer” comment “My Cool Printer”
Get printer settings:
rundll32 printui.dll,PrintUIEntry /Xg /n “printer”
Get printer settings saving results in a file:
rundll32 printui.dll,PrintUIEntry /f “results.txt” /Xg /n “printer”
Set printer settings command usage:
rundll32 printui.dll,PrintUIEntry /Xs /n “printer” ?
Store all printer settings into a file:
rundll32 printui.dll,PrintUIEntry /Ss /n “printer” /a “file.dat”
Restore all printer settings from a file:
rundll32 printui.dll,PrintUIEntry /Sr /n “printer” /a “file.dat”
Store printer information on level 2 into a file :
rundll32 printui.dll,PrintUIEntry /Ss /n “printer” /a “file.dat” 2
Restore  from a file printer security descriptor:
rundll32 printui.dll,PrintUIEntry /Sr /n “printer” /a “file.dat” s
Restore  from a file printer global devmode and printer data:
rundll32 printui.dll,PrintUIEntry /Sr /n “printer” /a “file.dat” g d
Restore  from a file minimum settings and resolve port name:
rundll32 printui.dll,PrintUIEntry /Sr /n “printer” /a “file.dat” m p

Clearing ARP table

May 27th, 2009 by shiraj

Click on Start—>Run—> type the following command click ok

netsh interface ip delete arpcache

Dynamic ARP cache entries update persist for 2-20 minutes depending on the system.

Windows 2003 Server = 10 minutes

Windows 2000 professional/Server = 10 minutes

Windows XP = 2 minutes

Solaris = 5 minutes

Delete IP address using arp command

arp -d <ip address>

Example

arp -d 10.1.1.2

Display arp table

arp -a

Add static entry to ARP table

arp -s <ip address> <mac address>

Example

arp -s 157.55.85.212 00-aa-00-62-c6-09

How to reset password on 3Com switch 2948

May 22nd, 2009 by shiraj

From the 3Com knowledge base:

********************
Baseline Switch 2948 – How to reset password on switch 2948
Problem:      How to reset password on switch 2948

The resetting of the password requires the installation of a console cable to the console port.

Be sure the terminal emulator program is set to VT-100 management using compatible, 38400 baud rate, no parity, 8 data bits and Console connection one stop bit.

Use the included cable, or be sure that the pin-out complies with a standard null-modem cable

Once the cable is connected, reboot the switch.  Type a Ctrl/C until you enter the failsafe mode.  This will be denoted with the prompt: “CFE>”

At the prompt execute the following commands:
CFE> passwrd
CFE> reset -sysreset

At this point the password has been reset.

resetting nvram pram on mac

May 20th, 2009 by shiraj

Try starting while holding the Command-Option-Shift-Delete keys all at the same time and see if it will let you startup/install.

Do you have any external drives you could install Tiger on first?

If the above doesn’t work, try this:

1. Start Mac and hold Option-Command-O-F keys
2. When the grey screen gets loaded type reset-nvram then press Return key
3. At next prompt type reset-all and the Mac will restart

See if that will allow install.