• 0

[Batch] How can I avoid/ignore Windows messages caused by the program?


Question

Hi,

I'm working on a Batch file to automatically remove old printers and install new drivers. It all works very well, except when the printers I want to remove are already gone. Windows will pop up and error that the printer is gone or can't be found and the program won't continue until the message is answered. I can't even click on the cmd prompt because the error has priority.

I don't care if the printer wasn't there. If that's the case, I want the program to move on.

I'm new to batch files, though. I'm not a practiced programmer either. Is there some sort of error handling that can answer Windows prompts or ignore them?

@ECHO OFF

:: Delete the HP P1006.
ECHO Deleting HP P1006 Printer........
rundll32 printui.dll,PrintUIEntry /dl /n "HP LaserJet P1006" /c\\%ComputerName%


:: Delete the Lexmark.
ECHO Deleting Lexmark Optra E+ Printer........
rundll32 printui.dll,PrintUIEntry /dl /n "Lexmark Optra E+ (MS)" /c\\%ComputerName%


:: Install the drivers.
ECHO Installing New HP P1006 Printer Drivers........
rundll32 printui.dll,PrintUIEntry /if /b "HP LaserJet P1006" /c\\%ComputerName% /f "C:\Temp\P1006_Install_Light\hpljp1005.inf" /r "USB001" /m "HP LaserJet P1006" 

:: Stop and Start the print spoolers so a restart is not neccessary.
ECHO Stopping and Start Print Spooler.........
net stop spooler

net start spooler

exit

2 answers to this question

Recommended Posts

  • 0

Have you tried adding /q ("Quiet") switch to your command?

Like:

rundll32 printui.dll,PrintUIEntry /q /dl /n "HP LaserJet P1006" /c\\%ComputerName%

You can execute rundll32 printui.dll,PrintUIEntry /? to see all available switches.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Saw this on Twitter/X. Can't imagine the emotional rollercoaster going on inside of her head.
    • It's telling how brainwashed  and triggered you are that you immediately think it's because he was MAGA.    There's tons of things he's done throughout his wrestling career alone that wrestling fans right wing/ or left wing have problems with.  Not to mention his personal life. 
    • UK enforces strict new online age checks today by Paul Hill As of today, July 25, 2025, new Ofcom regulations mandate that “highly effective” age checks are in place for online services. These new rules apply to any websites or platforms that host pornography, self-harm, suicide, or eating disorder content. Major platforms like Pornhub, Bluesky, Discord, Grindr, Reddit, and X have committed to implementing age-gating. These age checks are part of the broader Online Safety Act, which is designed to make the internet safer, particularly for kids. These measures move away from just confirming you’re 18 by clicking a button to having to actually verify your age with ID or a face scan, but this move is not without its critics. Starting today, Ofcom will actively check compliance with the new rules and start launching investigations into non-compliant services, starting next week. The current enforcement program that’s focused on studio porn services is extending to all platforms allowing user-shared pornographic material, not just those websites dedicated to that. Ofcom is also launching another enforcement program that will target websites specifically dedicated to harmful content like self-harm, suicide, eating disorders, and extreme violence/gore. Ofcom has strong enforcement powers under the Online Safety Act, it can dish out fines of up to 10% of qualifying worldwide revenue or £18 million. For the worst offenders, Ofcom can even get websites blocked in the UK. Ofcom is already investigating 11 companies that it doesn’t think are following the rules. Aside from age checks, Ofcom’s Codes also require websites to protect children from dangerous stunts, misogynistic, violent, hateful, or abusive material, and online bullying. Algorithms of social media will need to be configured to block harmful content in children’s feeds, for example. Ofcom will be launching an extensive monitoring program requiring risk assessments by August 7 and practical action disclosures by September 30. While some have criticized the Online Safety Act, research cited by Ofcom shows that 71% of UK parents think the changes will positively impact children’s online safety, with 77% being optimistic about the age checks specifically. With that said, a significant minority of parents (41%) are skeptical about whether tech firms will follow the rules. Source: Ofcom | Image via Depositphotos.com
    • Microsoft has known to toggle settings in Windows Updates.
    • Another Linux utility is being rewritten in Rust by David Uzondu Greenboot, the health check tool originally written in bash, is getting a rewrite in Rust, courtesy of engineers at Red Hat. This useful tool started in mid‑2018 as a Google Summer of Code project for Fedora IoT, designed to keep atomically updated systems from self-destructing after a bad update. At its heart, Greenboot is a framework that hooks into systemd to run health checks every time a machine boots. It looks for scripts in specific directories; anything in /etc/greenboot/check/required.d/ absolutely must pass. If a required script fails, Greenboot triggers a reboot to retry. After a few failed attempts, it executes scripts in /etc/greenboot/red.d/ and initiates a system rollback to the last known-good deployment, preventing an update from bricking your system. When all required checks succeed, it runs scripts from /etc/greenboot/green.d/ and marks the boot as successful by setting a GRUB environment variable. This whole process is kicked off by the greenboot-healthcheck.service before systemd's normal boot-complete.target is reached. As for why Red Hat is choosing this rewrite, it comes down to creating a more robust and secure utility. This is definitely not the only *-rs tool rewrite we have seen lately; you have probably heard about sudo-rs, which is a project to build a memory-safe replacement for the classic sudo utility. Building these fundamental system components in a memory-safe language like Rust helps eliminate entire categories of security vulnerabilities. According to the official Fedora change proposal, the rewrite expands support for both bootc and rpm-ostree based systems, whereas the original Bash version was built only for rpm-ostree. Red Hat developers have submitted a proposal to ship this new Rust version in Fedora 43. According to Phoronix, while the plan still needs a final vote from the Fedora Engineering and Steering Committee, it looks very likely to be approved. For current Fedora IoT users, the change promises to be a simple, seamless upgrade.
  • Recent Achievements

    • Very Popular
      d4l3d earned a badge
      Very Popular
    • Dedicated
      Stephen Leibowitz earned a badge
      Dedicated
    • Dedicated
      Snake Doc earned a badge
      Dedicated
    • One Month Later
      Philsl earned a badge
      One Month Later
    • One Month Later
      armandointerior640 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      625
    2. 2
      ATLien_0
      240
    3. 3
      Xenon
      163
    4. 4
      +FloatingFatMan
      124
    5. 5
      neufuse
      123
  • Tell a friend

    Love Neowin? Tell a friend!