Home > Back-end >  Powershell | Move mouse to coordinates and left-click
Powershell | Move mouse to coordinates and left-click

Time:03-15

I am setting up an automated deployment of a very old software. It's so old that there is no silent install option. I've checked the installer with ProcessExplorer and confirmed there were no silent switches in Strings. To get around this, I am installing the components manually.

My goal is to have my deployment software call a PowerShell script which calls the installer, then moves the mouse to the next button, and goes through the motions as an end-user would. I already have the deployment software performing the preparation steps, and calling the program installer. It will need some wait functions to account for different processing times among different computers. And it would need to be able to handle the script being called on computers with different sized screens.

Is this possible?

CodePudding user response:

As already commented - using a mouse won't be that easy with the requirement to make it work on different computers (screen size...). If PowerShell is required, you might try to use send keys:

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait("%n{TAB}{ENTER}")

Source: Send Keys in Powershell alt n {TAB} {ENTER}

I know software deployment tools (baramundi for example) might have built-in scripting capabilities to automate something like that, but you can built your own application that helps you with your installation. With Autoit you can create almost bulletproof installer if your installer is compatible. Just get Autoit, try if you can use the finder tool within "AutoIt Window Info" (try both x86 and x64). If it can directly "find" your buttons, you need you can wait for that window, and that button and then press it with controlClick function: https://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm

Third way - the best solution especially for old software - depending on the installation routine you might build your own installer. In some cases, copying the necessary folder, files, and registry entries might be enough. For other cases you might monitor your installation process with Procmon and do the other things that happen during normal installation. https://docs.microsoft.com/en-us/sysinternals/downloads/procmon Also using Procmon in a try and error deployment might be enough for you. Just copy the installation from a working client try to start the application, read the error message, and solve that with the help of actions you see that happened/failed in procmom.

  • Related