none
Exception calling AppActivate RRS feed

  • General discussion

  • Hi All,

    I have written a script to uninstall the Net Time service from a computer. The script is giving me desired result, but throwing error.

    $exe = "C:\Program Files (x86)\NetTime\unins000.exe"
    
    Add-Type -AssemblyName 'System.Windows.Forms'
    $ID = (Start-Process $exe -PassThru).id
    Sleep 1
    Add-Type -AssemblyName Microsoft.VisualBasic
    [Microsoft.VisualBasic.Interaction]::AppActivate($ID) 
    [System.Windows.Forms.SendKeys]::SendWait("No~")
    

    error I was getting is

    Exception calling "AppActivate" with "1" argument(s): "Process '{0}' was not found."
    At F:\powershell\Function\get-exe.ps1:7 char:1
    + [Microsoft.VisualBasic.Interaction]::AppActivate($ID)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ArgumentException
     
    

    I have confirmed that that the ID of the process is correct from task manager.

    • Changed type Bill_Stewart Friday, July 7, 2017 7:11 PM
    • Moved by Bill_Stewart Friday, July 7, 2017 7:11 PM This is not support forum for third party software
    Saturday, June 10, 2017 5:56 AM

All replies

  • You can't do that as you can now see.

    You can only use a correct uninstall string,.

    Check the registry for the uninstall string and contact the vendor for instructions on how to use their uninstaller.


    \_(ツ)_/

    Saturday, June 10, 2017 5:59 AM
  • even with the error, this script is uninstalling Net Time service from the computer.
    Saturday, June 10, 2017 6:09 AM
  • AppActivate cannot find the process you are looking for.  Why use it?

    You have to understand installer technology. The EXE is not the installer it is a stub that places a request to the system installer. All prompts that happen are from the system and not from the EXE> The exe likely just starts and exits after it send the message.

    To suppress all message you need to add parameters to the uninstall command such as "/quiet".  Ask the vendor for their quit uninstall parameters or look up the command in the registry.


    \_(ツ)_/

    Saturday, June 10, 2017 6:27 AM
  • You need to ask the vendor of your package how to do a silent uninstall. That is not a question we can can answer for you in this forum since we didn't write that installer.


    -- Bill Stewart [Bill_Stewart]

    Saturday, June 10, 2017 5:16 PM