Close an application in Powershell RRS feed

  • Question

  • i'm making and TCI/IP Printer install script, when I deploy the driver automatically the driver install tool aplication shows up.

    The problem is I want to close thisapplication by pressing the cancel button automatically, otherwise my script would stop in the middle. Sorry but I'm new with powershell, any advices??

    I already try the stop-process, -force, closemainwindoe and doesn't work.

    Thursday, October 30, 2014 3:07 PM

All replies

  • Get-Process | Where-Object { $_.Name -eq "THE_APP_YOU_WANT_CLOSED" } | stop-process -Force
    This should work as long as you are running your PowerShell session as administrator.
    • Proposed as answer by BF22 Thursday, January 22, 2015 8:49 PM
    Thursday, January 22, 2015 3:25 PM
  • First off, I want to mention something about Ben's suggestion. As a best practice, we always want to filter as close the left of our commands as possible, therefore, it would better to use the -Name parameter of Get-Process than to pipe it to the Where-Object cmdlet:

    Get-Process -Name NameOfProcess | Stop-Process

    Second, I don't think you're going to get PowerShell to "press cancel" for you. It seems the Stop-Process may be able to help, if you can truly determine what process to end. What might be best, though, is to determine how to deploy the drivers in a manner where it is completely silent--where there isn't a need to "press cancel."

    Friday, January 23, 2015 3:18 PM