JSI Tip 9960. How can I verify that the same printer shares exist on computer2 as exist on computer1?

Using RMTShare.exe, I have scripted SamePrinter.bat to report any printer shares that exists on computer1 that do not exists on computer2.

The syntax for using SamePrinter.bat is:

SamePrinter Computer1 Computer2

Where Computer1 and Computer2 are the NetBIOS computer names, and may not contain spaces.

NOTE: SamePrinter.bat requires that a printer share be from 1 to 12 characters and does not contain spaces.

SamePrinter.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax SamePrinter Computer1 Computer2&goto :EOF
set c1=%1
set c2=%2
set c1=%c1:"=%
set c1=\\%c1:\=%
set c2=%c2:"=%
set c2=\\%c2:\=%
set b1=FIND /V ":"
set b2=FIND /V "The command completed successfully."
for /f "Skip=4 Tokens=*" %%a in ('rmtshare %c1%^|%b1%^|%b2%') do (
 set line=%%a
 if "!line:~13,1!" NEQ " " call :c1prt !line:~0,12!
goto :EOF
set prt=%1
set OK=N
for /f "Skip=4 Tokens=*" %%b in ('rmtshare %c2%^|%b1%^|%b2%') do (
 set work=%%b
 if "!work:~13,1!" NEQ " " call :c2prt !work:~0,12!
if "%OK%" EQU "Y" goto :EOF
@echo %c1% - %prt% - does NOT exist on %c2%
goto :EOF
if /i "%1" NEQ "%prt%" goto :EOF
set OK=Y

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.