Trouble with Start-Process Installing Printer Driver

0
4
Asked By TechieTurtle123 On

Hey everyone! I'm working on a PowerShell script to standardize printer names across multiple PCs connected to the same printer with a specific IP. The script also aims to install the HP Universal Driver if it's not already installed. The issue I'm facing is that the Start-Process command isn't working as expected, and the driver isn't installing as it should. Here's a snippet of my script:

```powershell
$printerip = Read-Host "Enter Printer IP Address"
$printername = Read-Host "Enter Uniform Printer Name:"
Get-PrinterDriver
$printerdriver = "HP Universal Printing PS"
$checkdriver = Get-PrinterDriver -Name "HP Universal Printing PS"

if($checkdriver -eq $null) {
Write-Host "Driver not installed, installing driver now"
Start-Process -FilePath "\172.17.9.185companyitSoftware and DriversdriversHP PCL 6Install.exe" -ArgumentList "/s" -NoNewWindow -Wait
}
```

I confirmed the path is correct with Test-Path and I don't see any related processes when I check with Get-Process while the script runs. I would appreciate any help or ideas on why it's not working. Thanks!

3 Answers

Answered By ScriptSavvy99 On

Have you tried checking the exit code from the Start-Process command? You can do this by modifying your command to include `-Passthru`, which allows you to retrieve the exit code. It might give you insight on why it’s failing.

Answered By CodeNinja42 On

Instead of using Start-Process, consider running the command directly and checking `$LASTEXITCODE`. If you run it like this: `& '\172.17.9.185companyitSoftware and DriversdriversHP PCL 6Install.exe' /s`, you might get a clearer result, especially if it fails immediately.

Answered By PrintMasterX On

I often run into issues using executables on network paths. A workaround is to copy the EXE to a local path and execute it from there. You could also use `-RedirectStandardOutput` and `-RedirectStandardError` to see what's happening during the installation. If you have access to the driver files, you can install them manually without the EXE.

TechieTurtle123 -

I’ll give copying the EXE a try! Thanks for the tip!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.