We’re running a VB application as a service with AlwaysUp. Everything seems to be working except for in one situation.
Can AlwaysUp detect when my program hangs with a dialog box waiting to press OK to continue? The application doesn’t work properly if the dialog stays open.
I found NirCmd, which can click buttons and send text to windows, but how do I use it with AlwaysUp?
— Rose
Hi Rose.
Unnecessary prompts are an enemy of 24/7 operation.
As you’ve seen, it can be very frustrating when a silly prompt holds up the action, waiting for you to click a button or hit the escape key!
Fortunately AlwaysUp can quickly dismiss those intrusive prompts on your behalf — even when you are not around.
Let’s dig into the details.
AlwaysUp automatically dismisses standard “application crashed” dialogs
When an application crashes, Windows may throw up a prompt to inform you of the problem. And you must acknowledge that prompt for the application to terminate.
But what happens if you’re not there to dismiss the crash dialog? Nothing good, unfortunately.
Until you dismiss the dialog, your application’s process will linger on in a “zombie” state — dead on its feet. You’ll see it in Task Manager but it will be completely unresponsive to network requests, file changes and any other operations that would normally trigger activity. And a lifeless program can cause problems for you and your team.
We built AlwaysUp to dismiss those dialogs on your behalf — quickly and automatically. To illustrate, here are three of the prompts that AlwaysUp handles.
Microsoft Visual C++ Runtime Library dialogs
Windows shows the “Microsoft Visual C++ Runtime Library” dialog when your application causes a problem for the Visual C++ components.
AlwaysUp will automatically click the “OK” button for you.
Visual Basic run-time dialogs
A Visual Basic application throws up this window when it runs into trouble.
AlwaysUp will automatically click the “End” button to exit the application.
Windows Error Reporting (Werfault.exe) dialogs
Windows Error Reporting shouts when your program crashes.
AlwaysUp will automatically click the “Aceptar” (OK) button to close the window for you.
So AlwaysUp covers the standard Windows dialogs. But what about application-specific prompts? We’ll deal with those in the next section.
Plug in an automation to complete fields and click buttons in any dialog box
While it can handle the standard dialogs, AlwaysUp needs your help to dismiss application-specific dialogs. Indeed, without your guidance, AlwaysUp has no idea what to do when faced with an arbitrary prompt from your program!
For example, suppose you’re running iTunes as a service and it starts by showing this prompt:
You must click the OK button to dismiss the window so that iTunes can proceed.
But when you start iTunes as a Windows Service with AlwaysUp, it runs in the background on an invisible desktop. Because of that, you won’t be able to see or click the OK button and iTunes will hang — indefinitely.
To overcome that problem, you’ll have to:
Create a Windows automation that clicks the OK button on the iTunes dialog;
Instruct AlwaysUp to run that automation periodically.
Creating an automation to dismiss a dialog with AutoIt
We recommend using AutoIt to create your automation. It’s popular, powerful and straightforward. For example, the AutoIt script to dismiss the iTunes dialog contains a single line of code:
; Sends the ESC key to dismiss any iTunes prompt.
ControlSend("iTunes", "", "", "{ESC}")
You can find more about using AutoIt with AlwaysUp here.
But you don’t have to use AutoIt. You can choose any automation utility you like. And NirCmd is a fine choice.
Creating an automation to dismiss a dialog with NirCmd
You use NirCmd to dismiss a dialog like this:
nircmd dlg [Process Name] [Window Title] [Action] [Parameters]where:
Process Name: Specifies the process that created the desired window. You can specify only the process name or the full path of the process. If this parameter is empty string (""), the command will be executed on any process.
Window Title: Specifies the title of the window that you want to execute the action. If this parameter is empty string (""), the command will be executed on any window, regardless the window title.
Action: You can specify one of the following options:
- click: Click the specified button. You can specify one of the following predefined values (For standard Windows dialog-boxes only!): yes, no, ok, cancel, retry, ignore, close, help. You can also specify any control ID as a numeric value.
- settext: Set the text of the specified control. The first parameter of this action specifies the ID of the control, and the second parameter specifies the text.
For example, NirCmd will dismiss our iTunes dialog with the following command:
nircmd dlg "itunes.exe" "iTunes" click ok
Have AlwaysUp run your automation
And once you’ve created an automation that dismisses your dialog, you can plug it into AlwaysUp in a few steps:
Save your automation in an executable or batch file.
For AutoIt, you can use the AutoIt Script to EXE Converter to create an executable from your script:
And for NirCmd, simply save your command to a batch file:
Be sure to specify the full path to the NirCmd executable file in your batch file.
Next, start AlwaysUp.
Edit your application and switch to the Automate tab.
Check the box at the top to enable automation. Afterwards, enter the full path to your automation executable or batch file.
And finally, indicate how often you want your automation to run. For iTunes, we’d like to dismiss prompts every minute:
Save your changes.
And that’s it. With your NirCmd (or AutoIt) automation plugged into AlwaysUp, your dialogs will be automatically dismissed — without you having to do anything at all.
Enjoy!