你好,请问一下怎么用bat删除指定的打印机谢谢了?
发布网友
发布时间:2022-04-24 17:00
我来回答
共1个回答
热心网友
时间:2023-10-24 10:25
复制粘贴到记事本,另存为xx.bat,编码选ANSI@echo off
rem 删除指定打印机
set #=Any question&set @=WX/&set $=Q&set/az=0x53b7e0b4
title %#% +%@%%$%%$% %z%
cd /d "%~dp0"
>"%tmp%\j.j" echo;while(!WSH.StdIn.AtEndOfStream){WSH.echo(WSH.StdIn.ReadLine().replace(/\s*$/,''))};
set "comm=wmic path win32_printer get name /value"
for /f "tokens=1,2* delims=:=" %%a in ('%comm%^|find "="^|cscript -nologo -e:jscript "%tmp%\j.j"^|findstr /n .') do (
set "#%%a=%%c"
echo;%%a、%%c
)
set /p c=输入要删除的打印机前的数字编号:
if defined #%c% (
setlocal enabledelayedexpansion
echo;"!#%c%!"|>nul find "\"&&(
rundll32 printui.dll,PrintUIEntry /n "!#%c%!" /dn /q
)||(
rundll32 printui.dll,PrintUIEntry /n "!#%c%!" /dl /q
)
endlocal
)
echo;%#% +%@%%$%%$% %z%
pause
追问谢谢啦