{"id":10807,"date":"2024-01-29T07:09:43","date_gmt":"2024-01-29T15:09:43","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=10807"},"modified":"2024-01-29T07:09:43","modified_gmt":"2024-01-29T15:09:43","slug":"close-dialog-boxes-nircmd","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/close-dialog-boxes-nircmd\/","title":{"rendered":"Q&#038;A: Can AlwaysUp Close Dialog Boxes From My Application?"},"content":{"rendered":"<div align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"\/blog\/images\/qa-dismiss-dialog-boxes.webp\" style=\"margin-bottom:20px;\" title=\"Can AlwaysUp Close Dialog Boxes From My Application?\" alt=\"Can AlwaysUp Close Dialog Boxes From My Application?\" border=\"0\" width=\"380\" height=\"160\" \/><\/div>\n<div class=\"blog-qa-question-box\">\n<img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"https:\/\/cdn.coretechnologies.com\/images\/quotes-transparent-21x21.webp\" width=\"21\" height=\"21\" \/>&nbsp;&nbsp;We&#8217;re running a VB application as a service with AlwaysUp. Everything seems to be working except for in one situation.<\/p>\n<p>Can AlwaysUp detect when my program hangs with a dialog box waiting to press OK to continue? The application doesn&#8217;t work properly if the dialog stays open.<\/p>\n<p>I found <a href=\"https:\/\/nircmd.nirsoft.net\/dlg.html\" target=\"_blank\" rel=\"noopener\">NirCmd<\/a>, which can click buttons and send text to windows, but how do I use it with AlwaysUp?<\/p>\n<p align=\"right\">&mdash; Rose<\/p>\n<\/div>\n<p>Hi Rose.<\/p>\n<p>Unnecessary prompts are an enemy of 24\/7 operation.<\/p>\n<p>As you&#8217;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!<\/p>\n<p>Fortunately AlwaysUp can quickly dismiss those intrusive prompts on your behalf &mdash; even when you are not around.<\/p>\n<p>Let&#8217;s dig into the details.<\/p>\n<hr class=\"blog-section\">\n<h2 class=\"blog-caption\">AlwaysUp automatically dismisses standard &#8220;application crashed&#8221; dialogs<\/h2>\n<p>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.<\/p>\n<p>But what happens if you&#8217;re not there to dismiss the crash dialog? Nothing good, unfortunately.<\/p>\n<p>Until you dismiss the dialog, your application&#8217;s process will linger on in a &#8220;zombie&#8221; state &mdash; dead on its feet. You&#8217;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.<\/p>\n<p>We built AlwaysUp to dismiss those dialogs on your behalf &mdash; quickly and automatically. To illustrate, here are three of the prompts that AlwaysUp handles.<\/p>\n<h3 class=\"blog-caption\">Microsoft Visual C++ Runtime Library dialogs<\/h3>\n<div align=\"center\"><a href=\"\/blog\/images\/microsoft-runtime-error.png\" class=\"zoomPopup\" title=\"Microsoft Visual C++ Runtime Library dialog\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/microsoft-runtime-error.png\" title=\"Microsoft Visual C++ Runtime Library dialog (click to enlarge)\" alt=\"Microsoft Visual C++ Runtime Library dialog\" border=\"0\" \/><\/a><\/div>\n<p>Windows shows the &#8220;Microsoft Visual C++ Runtime Library&#8221; dialog when your application causes a problem for the <a href=\"https:\/\/learn.microsoft.com\/en-US\/cpp\/windows\/latest-supported-vc-redist\" target=\"_blank\" rel=\"noopener\">Visual C++ components<\/a>.<\/p>\n<p>AlwaysUp will automatically click the &#8220;OK&#8221; button for you.<\/p>\n<h3 class=\"blog-caption\">Visual Basic run-time dialogs<\/h3>\n<div align=\"center\"><a href=\"\/blog\/images\/microsoft-visual-basic-run-time-error.png\" class=\"zoomPopup\" title=\"Visual Basic run-time dialog\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/microsoft-visual-basic-run-time-error.png\" title=\"Visual Basic run-time dialog (click to enlarge)\" alt=\"Visual Basic run-time dialog\" border=\"0\" \/><\/a><\/div>\n<p>A <a href=\"https:\/\/en.wikipedia.org\/wiki\/Visual_Basic_for_Applications\" target=\"_blank\" rel=\"noopener\">Visual Basic<\/a> application throws up this window when it runs into trouble.<\/p>\n<p>AlwaysUp will automatically click the &#8220;End&#8221; button to exit the application.<\/p>\n<h3 class=\"blog-caption\">Windows Error Reporting (Werfault.exe) dialogs<\/h3>\n<div align=\"center\"><a href=\"\/blog\/images\/windows-error-reporting-dialog.png\" class=\"zoomPopup\" title=\"Windows Error Reporting (Werfault.exe) dialog\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/windows-error-reporting-dialog.png\" title=\"Windows Error Reporting (Werfault.exe) dialog (click to enlarge)\" alt=\"Windows Error Reporting (Werfault.exe) dialog\" border=\"0\" \/><\/a><\/div>\n<p><a href=\"https:\/\/learn.microsoft.com\/en-us\/troubleshoot\/windows-client\/system-management-components\/windows-error-reporting-diagnostics-enablement-guidance\" target=\"_blank\" rel=\"noopener\">Windows Error Reporting<\/a> shouts when your program crashes.<\/p>\n<p>AlwaysUp will automatically click the &#8220;Aceptar&#8221; (OK) button to close the window for you.<\/p>\n<p style=\"margin-top: 30px\">\nSo AlwaysUp covers the standard Windows dialogs. But what about application-specific prompts? We&#8217;ll deal with those in the next section.\n<\/p>\n<hr class=\"blog-section\">\n<h2 class=\"blog-caption\">Plug in an automation to complete fields and click buttons in any dialog box<\/h2>\n<p>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!<\/p>\n<p>For example, suppose you&#8217;re running <a href=\"https:\/\/www.apple.com\/itunes\/\" target=\"_blank\" rel=\"noopener\">iTunes<\/a> as a service and it starts by showing this prompt:<\/p>\n<div align=\"center\"><a href=\"\/products\/AlwaysUp\/Apps\/itunes-problem-with-audio-configuration.png\" class=\"zoomPopup\" title=\"iTunes dialog\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/products\/AlwaysUp\/Apps\/itunes-problem-with-audio-configuration.png\" title=\"iTunes dialog (click to enlarge)\" alt=\"iTunes dialog\" border=\"0\" \/><\/a><\/div>\n<p>You must click the OK button to dismiss the window so that iTunes can proceed.<\/p>\n<p>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&#8217;t be able to see or click the OK button and iTunes will hang &mdash; indefinitely.<\/p>\n<p>To overcome that problem, you&#8217;ll have to:<\/p>\n<ol style=\"margin-bottom:24px\">\n<li>\n<p>Create a Windows automation that clicks the OK button on the iTunes dialog;<\/p>\n<\/li>\n<li>\n<p>Instruct AlwaysUp to run that automation periodically.<\/p>\n<\/li>\n<\/ol>\n<h3 class=\"blog-caption\">Creating an automation to dismiss a dialog with AutoIt<\/h3>\n<p>We recommend using <a href=\"https:\/\/www.autoitscript.com\/\" target=\"_blank\" rel=\"noopener\">AutoIt<\/a> to create your automation. It&#8217;s popular, powerful and straightforward. For example, the AutoIt script to dismiss the iTunes dialog contains a single line of code:<\/p>\n<div class=\"code-box\">\n; Sends the ESC key to dismiss any iTunes prompt.<br \/>\nControlSend(&quot;iTunes&quot;, &quot;&quot;, &quot;&quot;, &quot;{ESC}&quot;)\n<\/div>\n<p>You can find more about <a href=\"\/products\/AlwaysUp\/AutoIt\/\">using AutoIt with AlwaysUp here<\/a>.<\/p>\n<p>But you don&#8217;t have to use AutoIt. You can choose any automation utility you like. And NirCmd is a fine choice. <\/p>\n<h3 class=\"blog-caption\">Creating an automation to dismiss a dialog with NirCmd<\/h3>\n<p>You use NirCmd to dismiss a dialog like this:<\/p>\n<div class=\"code-box\">\n<b>nircmd dlg [Process Name] [Window Title] [Action] [Parameters]<\/b><\/p>\n<p>where:<\/p>\n<p><b>Process Name<\/b>: 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 (&quot;&quot;), the command will be executed on any process.<\/p>\n<p><b>Window Title<\/b>: Specifies the title of the window that you want to execute the action. If this parameter is empty string (&quot;&quot;), the command will be executed on any window, regardless the window title.<\/p>\n<p><b>Action<\/b>: You can specify one of the following options:<\/p>\n<ul>\n<li><b>click<\/b>: 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.<\/li>\n<li><b>settext<\/b>: 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.<\/li>\n<\/ul>\n<\/div>\n<p>For example, NirCmd will dismiss our iTunes dialog with the following command:<\/p>\n<div class=\"code-box\">\nnircmd dlg &quot;itunes.exe&quot; &quot;iTunes&quot; click ok\n<\/div>\n<h3 class=\"blog-caption\">Have AlwaysUp run your automation<\/h3>\n<p>And once you&#8217;ve created an automation that dismisses your dialog, you can plug it into AlwaysUp in a few steps:<\/p>\n<ol style=\"margin-bottom:24px\">\n<li>\n<p>Save your automation in an executable or batch file.<\/p>\n<p>For AutoIt, you can use the <b>AutoIt Script to EXE Converter<\/b> to create an executable from your script:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/convert-autoit-script-to-exe.png\" class=\"zoomPopup\" title=\"Convert your AutoIt script to an executable\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/convert-autoit-script-to-exe.png\" title=\"Convert your AutoIt script to an executable (click to enlarge)\" alt=\"Convert your AutoIt script to an executable\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>And for NirCmd, simply save your command to a batch file:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/dismiss-itunes-dialog-nircmd-batch-file.png\" class=\"zoomPopup\" title=\"NirCmd batch file\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/dismiss-itunes-dialog-nircmd-batch-file.png\" title=\"NirCmd batch file (click to enlarge)\" alt=\"NirCmd batch file\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Be sure to specify the full path to the NirCmd executable file in your batch file.<\/p>\n<\/li>\n<li>\n<p>Next, start AlwaysUp.<\/p>\n<\/li>\n<li>\n<p>Edit your application and switch to the <b>Automate<\/b> tab.<\/p>\n<\/li>\n<li>\n<p>Check the box at the top to enable automation. Afterwards, enter the full path to your automation executable or batch file.<\/p>\n<\/li>\n<li>\n<p>And finally, indicate how often you want your automation to run. For iTunes, we&#8217;d like to dismiss prompts every minute:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/alwaysup-nircmd-automation.png\" class=\"zoomPopup\" title=\"Install your NirCmd automation batch file\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/alwaysup-nircmd-automation.png\" title=\"Install your NirCmd automation batch file (click to enlarge)\" alt=\"Install your NirCmd automation batch file\" border=\"0\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>Save your changes.<\/p>\n<\/li>\n<\/ol>\n<hr class=\"blog-section\">\n<p style=\"margin-top: 30px\">\nAnd that&#8217;s it. With your NirCmd (or AutoIt) automation plugged into AlwaysUp, your dialogs will be automatically dismissed &mdash; without you having to do anything at all.<\/p>\n<p>Enjoy!\n<\/p>\n<div style=\"margin-top:30px\" align=\"center\">\n<div class=\"cta-button-1\">\n<table role=\"presentation\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"left\">\n<tbody>\n<tr>\n<td align=\"center\"><a href=\"\/blog\/tag\/alwaysup-tag\/\" title=\"More articles about AlwaysUp\"><span><nobr>More articles about AlwaysUp&#8230;<\/nobr><\/span><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<!-- relpost-thumb-wrapper --><div class=\"relpost-thumb-wrapper\"><!-- filter-class --><div class=\"relpost-thumb-container\"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }<\/style><h3>You may also like...<\/h3><div style=\"clear: both\"><\/div><div style=\"clear: both\"><\/div><!-- relpost-block-container --><div class=\"relpost-block-container relpost-block-column-layout\" style=\"--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2\"><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/stop-plex-windows-service\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: How do I Avoid Errors when Stopping my Plex Windows Service?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/plex-logo-2-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q&amp;A: How do I Avoid Errors when Stopping my Plex Windows Service?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/miscellaneous\/artwork-from-our-web-site\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Artwork from our Web Site\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/alwaysup-boxshot-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Artwork from our Web Site<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/windows\/getting-ready-for-windows-11\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Getting ready for Windows 11\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/windows-11-preview-logo-150x150-1.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Getting ready for Windows 11<\/h2><\/div><\/div><\/a><\/div><!-- close relpost-block-container --><div style=\"clear: both\"><\/div><\/div><!-- close filter class --><\/div><!-- close relpost-thumb-wrapper -->","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;We&#8217;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&#8217;t &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/close-dialog-boxes-nircmd\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":12272,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[26,35,40,341,340,127],"class_list":["post-10807","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alwaysup","tag-alwaysup-tag","tag-autoit","tag-automation","tag-dialog-box","tag-nircmd","tag-qa"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/10807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=10807"}],"version-history":[{"count":34,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/10807\/revisions"}],"predecessor-version":[{"id":12329,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/10807\/revisions\/12329"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/12272"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=10807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=10807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=10807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}