Suggestions for a bad PowerShell Script - powershell

We have a legacy server service running on a Windows 7 desktop that keeps crashing with a popup window reporting a memory error. The popup stops all processing on the machine. Once the "OK" button is clicked on the popup the system recovers and moves on. The root problem appears to be inside a compiled DLL that the application uses.
This popup usually happens between 9pm and 11pm every couple days.
It happens when no one is signed into the PC, so the popup displays in front of the CTRL+ALT+Delete message for signing in.
I can click OK and it continues processing, signing into the computer.
CHALLENGE:
This is a legacy application that will be replaced when budget allows (maybe next Summer) so there is no budget for upgrade or paying a consultant to fix the root problem.
All we need to do is click the OK button when the "Application Popup" event is thrown (logged in the Event Manager)
I know that it would be WRONG to write a script to satisfy the popup. Fixing the root cause is the CORRECT action.. but we have no support to spend money at this time. And since it's a compiled DLL, we can't fix the code.
Is there a PowerShell script that could:
Watch for a specific event "Application Popup" and if it occurs simulate pressing the ENTER key?
Run in the background, signed out of a user account.
If PowerShell isn't the answer, is there a better macro or script tool to get us by?
I know it's "bad practice" but we just need to get along until we get some budget dollars.

Powershell probably isn't the best answer in this case. I'd suggest using something like AutoIt (the WinWaitActive function would be useful in your case).
I have used AutoIt in the past and have found it very useful for Windows GUI automation.

Related

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

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

eclipse stop popup "Web launch already running"

I am developing in PHP with Xdebug and for some reason every now and then the debug session stops working, so i click again the debug button but it gives me this error all the time "Web launch already running", so i have to go to Debug Perspective and click "Terminate and Relaunch".
Is there a way to make eclipse automatically terminate and relaunch or launch two sessions or don't show this popup, for 2 years this popup has been bugging me xD
As noted in response to questions like this one and this one, the best current solution appears to be binding "Terminate and Relaunch" to a keyboard shortcut.
Not automatic, but at least a lot less clicking around.
I have taken care of pesky popups in Eclipse with AutoHotkey script which have worked very well. I could create an AutoHotkey script which sends specific keystrokes automatically every time there is a specific pop-up.
So the flow I had in mind was as follows :
You click on the debug button -> The Error popup appears and as soon as that happens the AutoHotKey script kicks in and automatically does what you have to do manually.
If you think that might be worth looking into then we can talk more in a Chat session somewhere. I would need some information about the Pop up using the AU3_Spy.exe bundled with the AutoHotkey Installer.
Searching on Google, I found that many people have the same problem.
Bellow are some links that help you, I think:
https://aptanastudio.tenderapp.com/discussions/questions/123-definitive-installation-guide-for-php-debugging-on-linuxubuntu
A good article: http://www.latenightpc.com/blog/archives/2008/05/24/a-complete-lamp-development-environment-xampp-eclipse-pdt-and-xdebug
See this, too: http://www.eclipse.org/forums/index.php/m/57493/
Take a look here, too: Getting error in XDEBUG
So, read and try, read and try.

Dismiss pop-up windows from outside application with script?

I have sort of an unorthodox question/idea. I have a hydrological modeling program that is a bit buggy. I do not have access to the source code. This modeling program runs 24/7 and periodically produces assertion errors (and sometimes runtime errors) and a resulting pop-up window. Often it produces a "Send Error Message/Don't Send" pop-up only. See attached .jpgs for examples.
These windows halt all further program execution until it is dismissed (by clicking "Ignore" "Don't Send" or "OK" respectively). The assertion errors do not appear to affect program function. From the investigating I've done on dbheap.c it is likely an issue with the modeling program deallocating memory improperly at the end of a run.
I would like the program to always continue running and producing its forecasting export products even in the event of one of these errors (which, again, appear to have no effect on program function). I would like to dismiss these pop-up windows from outside the application (via a script) so that they do not halt program execution. Does Windows have a means for monitoring and/or dismissing program generated pop-ups from outside the application?
You could write a simple application which forces the application to do things. With Winspector/Spy++ or Winsight you can see all the objects in a windows application. You could check periodically for a popup and then click a (maybe always the first) button. Windows has a API/syscall and with it, it is possible to send a message to a window (handle) of your choice (http://msdn.microsoft.com/en-us/library/windows/desktop/ms644944(v=vs.85).aspx).

Is there a way to automatically log onto a Windows XP machine at specific time?

How to set a specific logon time for a specific user on Windows XP?
For example, the computer is an "always on machine" and most of the time no one is logged on. I want to set a time for my user to log on, without someone actually having to be in front of the machine. I've tried a workaround with the built-in auto logon function (control userpassword2), but I still need a secure system as I'm not the only user, and would still want a password even if I was the only user.
I have searched for third party software, but to no avail. I've a good knowledge of batch and Python scripting and a little of Java, so any pointers with any of those would help.
How can it be "secure" if it logs you on without you being there? Surely it would be better for it to wait for you to type in a password (i.e. the login prompt)?
If you want a fast "startup" time, then you can lock the workstation (ctrl+alt+del to open the Task Manager and then click 'Lock'. This shows a dialog just like the login prompt, but when you enter your password you instantly continue your existing session). Or if you want to be more eco friendly, put your PC into Sleep mode, which most PCs will return from (again with an optional password prompt) in less than 5 seconds.
One way I just thought of: Run a Vnc Server, and hack into an open source viewer program. Then you can rig it with some code to pass keyboard commands back into the computer, maybe implement some screen scraping to make sure it only does it when appropriate.
But seriously, there has to be a better way. Why are you trying to do this?

Strange behavior by the BDE Administrator

Logged into my Windows XP SP2 computer using my normal user account (which has Local Admin privileges), when I start the BDE Administrator -- either from the Control Panel or from the BDEADMIN.EXE directly -- I never get the GUI. It shows up on my task bar, and shows up in the Task Manager, but the GUI never appears. I can close the program by right-clicking on the task bar and choosing close. (note that "never" means not within 5 minutes of launching the program)
If I log into the same exact computer using a different user account (which also has Local Admin privileges), when I start the BDE Administrator, it loads the GUI within a couple seconds.
I used to be able to use the BDE Administrator while logged in under my normal user account, so it's not like this has always been a problem.
While this issue may not be directly programming related, it does make developing and testing a pain when I have to log off and back on a couple of times just to make changes to my BDE configuration.
I am totally stumped. Any idea what might be causing this odd behavior?
One idea is that you may have had two screens running on this box and dragged the window off screen.
Just search for the registry keys that control where the window opens up and delete them. Alternatively, you should be able to right click on the program in the task bar and select Move. Then use your arrow keys to bring it back.
Regardless, I'm voting to close.