Get default printer name from command line?

前端 未结 7 1336
盖世英雄少女心
盖世英雄少女心 2020-12-31 08:02

Microsoft Windows XP comes with a VBS script to manage local and network printers from the command line:

To Get the default printer details from command line:

<
7条回答
  •  滥情空心
    2020-12-31 08:13

    Using a batch file (no VBScript files):

    @echo off
    
    ::Get printer CLSID
    for /f %%a in ('reg query HKCU\Printers\Defaults') do (set regkey=%%a)
    ::Get printer name from the previous CLSID
    
    for /f "tokens=3*" %%a in ('reg query %regkey%') do (set printername=%%a %%b)
    echo Printer name is: %printername%
    

    I wish that could help you

提交回复
热议问题