- @echo off
- :: Use ASCII characters only
- setlocal
-
- :: Set printer name and color mode
- set PRINTER_NAME=HP LaserJet Pro MFP M428fdw
- set COLOR_MODE=2
- :: 1=Color, 2=Black and White (depends on printer driver)
-
- echo Setting printer "%PRINTER_NAME%" color mode to %COLOR_MODE%...
-
- :: Use Get-WmiObject instead of Get-CimInstance
- powershell -command "$printer = Get-WmiObject -Class Win32_Printer -Filter \"Name='%PRINTER_NAME%'\"; if($printer) { $settings = $printer.GetDevMode(1); if($settings) { $settings.Color = %COLOR_MODE%; $printer.SetDevMode($settings); Write-Host 'Settings applied successfully!' } }"
-
- echo Printer settings completed.
- pause
复制代码 试试这个 |