Can you program a powershell script to press next in an install wizard? - powershell

I'd like to create a Powershell script to press the next button in an installation wizard.
I'm troubleshooting a script that a client wrote to help them automate the process of installing software. This script can allegedly fully install any program (with some small amount of customization from program to program).
Now I've gotten it to work to a point where it launches the install wizard, but then nothing happens. Their problem only happens further down the install process, but I can't seem to figure out why the first part of it being able to press next doesn't work.
I can provide code if necessary.
What line of code I should look for in the script that could make the script push the "next" and/or "continue" buttons?

Can you? Probably.
Powershell has access to .Net API and even native Windows API, so you could go low-level enough to enumerate windows in the installer window, find the window labeled 'Next' and send a pair of mouseDown, mouseUp events to the button.
Should you? Probably not.
As mentioned in comments, any good installer system supports some method of installing silently. MSI, if I recall correctly, has a way of recording manual steps performed by a user and store them in a Response File. Then you may pass the .rsp file in later executions of the installer.
See other answers:
How to make better use of msi files

Related

Automating Upload through Windows File Explorer in Microsoft Edge

I am trying to automate a web process using selenium.
The process clicks an "upload image" button and then sends the file name to a Windows File Explorer Window.
My solution as of now is to use selenium to click the "upload image" button and then to use a VBscript, via the sendKeys command, to send the file name to the active windows file explorer window.
As others have noted this causes some issues, foremost of which is that accidently focusing on another window sends the keys to it instead of file explorer.
I'm trying to make this process less "hacky".
I know MS Edge uses a Windows Utilities subprocess to open the file explorer window.
As of now, I can get the Id of this subprocess, but in a round about way, namely, by finding the most recently created subprocess managed by the browser. Obviously, this is a far cry from automation.
Using windows PowerShell, I've I have not managed to locate any information about this subprocess that could help with my automation task. For example, I could not get any unique identifying characteristics of the subprocess other than its process Id and I can't access its standard input. So far, all I can do is kill the sub process.
What I'm looking for is a rough outline (no code, just an architectural overview) of what it would take to do in PowerShell, what MS edge does after invoking the Windows Utility subprocess to upload a file to a website.
If someone has any suggestions on books I can read, I'd appreciate that as well.
Just looking for someone to point me in the right direction, really.

Powershell won't pass keystroke to cli window

I first need to offer the disclaimer that I am barely a novice when it comes to scripting or coding, so I might be doing this all wrong in the first place. I'm running into an issue with a script I had written in powershell a while ago that is used on several hundred computers in my company daily to automate starting a certain app that everyone uses. So far everyone else hasn't had an issue except one machine.
Normally when I run the script, it starts the services and cli for the program which opens in a new window. Then the script, still open behind that, sends all of the key commands to that cli window, pauses for a brief line of user input after which it closes that cli window, does a few other clean up tasks and closes out itself.
The only difference on this one machine that's not working is the script won't pass the keystrokes to the cli window. If I put them in manually including the normal user input, it finishes the rest of the script just fine, but the cli window is just not receiving the keystroke input from the main script.
The only part of the script that send the keystrokes to the cli window is a few lines of this:
[System.Windows.Forms.SendKeys]::SendWait("Text{Enter}")
I have tried using the sleep command before and in between the key commands to make sure it's not going through the keystrokes to early. I've checked and windows had gone through an Update two days ago, but we would've heard about this issue right then if that was it. I'm at a loss for what the issue could be and would apreciate and help, tips, or direction to help figure this one out.
Is the console window the active window when the keys are sent? The documentation for the class you are calling indicates that it sends the keys to the active window. Not only that, but the documentation also seems to indicate that there are some issues that developers have run into when using that class to sends keys. I would try using the autoit powershell module instead. Autoit is its own scripting language which specializes in automating windows processes and being capable of automating interactions with windows forms, but also comes bundled with its own powershell module that I think is exactly what you need, so I would download the portable "zip" package, extract the powershell module from "Autoitx", and that should help you accomplish what you need
PowerShell automation especially when using SendKeys can / is glitchy due to many varying reasons. Can you use SendKeys sure, but you have to know the environment it will be run in and the needed performance details. Hence your futzing/guessing with Sleep.
There are purpose-built tools to help.
Auto HotKey
'PowerShell auto hotkey'
or the UIAutomation tool
'PowerShell automating other applications'

Install4j uninstall other program

The examples I have found of Install4j are simple wizard generated and don't show more complex logic. I need some help to do the following in Install4j v6.
Desired flow
Display the initial welcome screen
check for other program being installed in Windows
if other program is installed
Display message to user with confirmation to remove the other program
If confirmed, run the Windows Uninstaller for the other program
If not confirmed, exit the installer
I found question 27497335 which describes how to search the Windows Registry. Also question 10282814 which describes how to run a Windows uninstall.
I'm unsure of how to use these in my install to achieve the above flow.
To organize screen flow, use screen groups and set the condition expression on the screen groups or on single screens.
To see an example, add a "standalone updater" application on the "Installer->Screens & Actions" step. It uses screen groups with condition expressions to behave in different ways depending on whether the installation is up to date or not.

Automated Updating of a Program via powershell

I am trying to updating a software that is company wide. When the update is applied to the server, the client machines recognize they need an update and ask if you wish to update or not. To update, the user would need to run as admin, which is'nt an option in this case.
We would like to automate this process using powershell, using the Invoke-Command feature. For the most part, the only thing that the update does is copy new files to the programs folder, which we have achieved with robocopy. However, there is one registry key that needs to be added in multiple locations. There is a setup file that does this, but requires a user (with admin privileges) click a couple buttons, and we want this to be completely automated.
So I guess the short version of my question is, what is the best way to handle the registry changes that setup.exe does? It would be nice if there was a way to invoke the script that the executable does.
As for my question, I solved the problem with a slightly diferent approach. (One that should have been tried initially)
When (ProgramName).exe is run, if it sees that it needs updated, it runs a program called (ProgramName).setup.exe with the parameters :
Client="Local folder" server="server location"
These parameters did NOT work from the command line, however, and so I ended up using a powershell script to make a scheduled task that ran (ProgramName).setup.exe with said parameters.
Another huge advantage to this was the fact that I could create an icon that allowed a regular user to run the scheduled task with admin privileges. I couldn't setup a shortcut directly, however, I wrote an AUTO-it Executable that would run the task as admin.
I hope someone can get some level of help out of this post!

Interactive Perl programming in Sublime 3 (Ubuntu)

Practically all of the exercises in my introductory Perl book have so far required taking input, which is causing me some challenges with Sublime Text 3. I set up the custom build file from this post to run scripts directly and I've also installed REPL on top of that, but I'm still unable to provide input through the bottom console.
Is there a way to enable input for scripts built via Ctrl+B, preferably with the console messages getting a little less in the way? I'm currently stuck with having to fire up the terminal every time, which doesn't make for a particularly smooth learning experience.
This doesn't really help you with your Sublime issue, but you mention firing up a terminal every time isn't helping you learn - here's the way I do it when I'm either learning or rapidly prototyping: Simply setup a folder on your local machine, called sync or something. Create a similar folder on your terminal server.
Now use an app (I use WinSCP and use Keep Remote Directory Up To Date setting) to sync. Every time you press save in your text editor, the new script is automatically uploaded to your terminal server, you can now just alt+tab to your terminal and run the script. Works very well for me and enabled really easy rapid prototyping.