0

Can someone help me with a simple script that sends two keys (TAB and then Enter) to an uninstall prompt? I am trying to silently uninstall IObit Uninstaller but the /silent /supressmsgboxes does not work.

This is what I have so far:

Start-Process "C:\Program Files (x86)\IObit\IObit Uninstaller\unins000.exe"

[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")

It doesn't return an error, but it doesn't work either.

Regards, Alex

Steven
  • 6,817
  • 1
  • 14
  • 14
  • 1
    Please show the code you have already tried and explain what _does not work_ means. Got error messages? Please add these to the question too. – Theo Feb 09 '21 at 13:46
  • 1
    From [here](https://gist.github.com/choco-bot/6d7bcc406412f0341e5ee19a199f8d86) (line 10), I think there is only one switch `/SILENT` needed: `& 'C:\Program Files (x86)\IObit\IObit Uninstaller\unins000.exe' /SILENT` – Theo Feb 09 '21 at 14:23

1 Answers1

0

Goes without saying, but I would play with the uninstaller and make sure I've exhausted all the options before I play with any Send Keys paradigm.

I don't know exactly how you are running this. But, if you are going to send keys to the uninstall process there are a few things to look at.

First I think you have to add the assembly like:

Add-Type -AssemblyName System.Windows.Forms

So I don't know why you didn't see errors, but if you were running a side script it may have exited. Either way Add-Type won't hurt...

Second, I think you have to make sure the uninstaller is in focus. There's an example of doing so using the WScript.Shell COM objects here

In my rather lean experience with this it's a little harder to do Purely in PowerShell, but there's some work on PowerShell.org here. if you want to play with it.

Goggle has tons of similar things leveraging the Win32 API.

Steven
  • 6,817
  • 1
  • 14
  • 14