可不可以用批处理设置共享打印机?怎样写?

来源:百度知道 编辑:UC知道 时间:2024/06/17 23:08:53
比如,我在LPT1上接了一台叫CANONLBP的打印机。现在需要用一个批处理实现把这台计算机共享或不共享。不知道改怎么写。

说明一下,我问的不是怎么去连接别人的共享打印机。哪位高人请帮我写一下命令。非常感谢。

供参考,需要几个文件来配置
CODE: [Copy to clipboard]
--------------------------------------------------------------------------------

echo off
cls

rem 以下是判断端口
set count=0
:addreginfo
set /a count=%count%+1
if exist 打印机%count%.txt (set filename=打印机%count%.txt) else (goto eof)
for /f "tokens=2 delims==" %%a in ('type %filename% ^|findstr /I "打印机IP="') do set pIP=%%a
if /I "%pIP%"=="LPT1:" goto addreginfo
if /I "%pIP%"=="LPT2:" goto addreginfo

rem 以下是添加端口在注册表中的信息
set regpath1=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_
set regpath2=HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_
:addreg1
@reg add "%regpath1%%pip%" /v "Protocol" /d "00000001&qu