{"id":2280,"date":"2016-05-02T09:00:33","date_gmt":"2016-05-02T16:00:33","guid":{"rendered":"http:\/\/www.coretechnologies.com\/blog\/?p=2280"},"modified":"2022-04-19T22:10:17","modified_gmt":"2022-04-20T05:10:17","slug":"dismiss-popups-dialog-boxes","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/windows-services\/dismiss-popups-dialog-boxes\/","title":{"rendered":"How to Automatically Dismiss Popups from a Windows Service"},"content":{"rendered":"<div align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load image-padding\" src=\"\/blog\/images\/outlook-security-popup.webp\" title=\"Outlook Security Popup\" alt=\"Outlook Security Popup\" border=\"0\" width=\"423\" height=\"236\" \/><\/div>\n<h2><b>Why Windows Services Should Avoid Showing Popups\/Dialog Boxes<\/b><\/h2>\n<p>Unlike a regular application (like Microsoft Word) that you launch from a desktop icon and actively work with to accomplish a specific task, a Windows Service is designed to start when your computer boots and run entirely in the background &#8212; even if you never log on.<\/p>\n<p>Yet despite this design philosophy, there is no restriction that actually prevents a Windows Service from displaying windows and trying to interact with users logged on to the PC. Indeed, such &#8220;Interactive Services&#8221; were encouraged in Windows XP and Windows Server 2003, but Microsoft changed their tune in Windows Vista. In our opinion, a couple of glaring problems caused the folks in Redmond to reverse course and actively discourage Windows Services from trying to get the desktop user&#8217;s attention:<\/p>\n<ol>\n<li>\n<h3>What happens when no one is logged on?<\/h3>\n<p>It is unclear what should happen when a Windows Service shows a prompt and no user is there to answer it. Holding up the action while waiting for someone to log on and click a button can be problematic for tasks designed to perform important tasks, 24\/7.<\/p>\n<\/li>\n<li>\n<h3>What happens when several users are logged on?<\/h3>\n<p>When a service throws up a prompt, which of the multiple users logged on should be allowed to respond to that window? One? All?<\/p>\n<\/li>\n<\/ol>\n<p>These thorny issues should discourage anyone from writing an interactive service today!<\/p>\n<p>But what is you have inherited a legacy service implemented under the more permissive Windows XP or Server 2003 rules? What if commercial realities force you to run an interactive application as a windows service with a <a href=\"\/products\/AlwaysUp\/\">service wrapper like AlwaysUp<\/a>? How do you keep those services running without interruption, getting around annoying prompts that would otherwise stall an important process?<\/p>\n<h2><b>Three Ways to Automatically Dismiss Dialog Boxes and Popups<\/b><\/h2>\n<ol>\n<li>\n<h3 style=\"margin-top:30px;\">Write a Custom AutoIt Script<\/h3>\n<p>\n<a href=\"https:\/\/www.autoitscript.com\/site\/autoit\/\" target=\"_blank\" rel=\"noopener noreferrer\">AutoIt<\/a> is a free scripting language designed for automating the Windows GUI. With this powerful tool, you can easily write scripts to activate windows, click buttons, check boxes, enter text and much more.\n<\/p>\n<p>\nFor example, this AutoIt script clicks the &#8220;OK&#8221; button on a window named &#8220;OCR Error&#8221;:\n<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\">; Try to bring the window to the top, to\r\n; prepare it for input.\r\n<span style=\"color: #0066BB; font-weight: bold\">WinActivate<\/span>(<span style=\"background-color: #fff0f0\">&quot;OCR Error&quot;<\/span>);\r\n \r\n; Click the OK button in the window.\r\n<span style=\"color: #0066BB; font-weight: bold\">ControlClick<\/span>(<span style=\"background-color: #fff0f0\">&quot;OCR Error&quot;<\/span>, <span style=\"background-color: #fff0f0\">&quot;OK&quot;<\/span>, <span style=\"background-color: #fff0f0\">&quot;&quot;<\/span>);\r\n<\/pre>\n<\/div>\n<p>\nNote that an AutoIt script can be compiled into an executable to run on any machine &#8212; even those without AutoIt installed.\n<\/p>\n<\/li>\n<li>\n<h3 style=\"margin-top:30px;\">Buy Buzof, the &#8220;Annoying Windows Eliminator&#8221;<\/h3>\n<p>\n<a href=\"https:\/\/basta.com\/buzof\" target=\"_blank\" rel=\"noopener noreferrer\">Buzof<\/a> is a commercial utility that makes it easy for non-programmers to automatically answer Windows prompts. Its point and click interface enables you to &#8220;train&#8221; the software to take the appropriate action on those annoying popups. Here is what Buzof looks like when configured to watch for four popups, clicking the &#8220;Yes&#8221; or &#8220;No&#8221; buttons:\n<\/p>\n<div align=\"left\"><img decoding=\"async\" src=\"\/blog\/images\/buzof-screenshot.png\" border=\"0\" title=\"Buzof\" alt=\"Buzof\" \/><\/div>\n<p>\nNote that Buzof is really meant for clicking buttons and other simple actions. More complex situations, such as checking a box and subsequently clicking a button or typing in a user name, are beyond its abilities.\n<\/p>\n<\/li>\n<li>\n<h3 style=\"margin-top:30px;\">Develop your own Windows GUI Utility<\/h3>\n<p>\nIf you are an experienced Windows programmer, then it won&#8217;t be too difficult to create your own solution. This may be a good investment of your time if using AutoIt or purchasing Buzof are not viable options.\n<\/p>\n<\/li>\n<\/ol>\n<h2><b>How to Run your Automated Solution on the Isolated Session 0 Desktop<\/b><\/h2>\n<p>\nOnce you have settled on a method to automatically dispatch the dialog boxes and popups, you must now set it up to run on the desktop where Windows Services run &#8212; in <a href=\"\/WindowsServices\/FAQ.html#WhatIsSession0Isolation\">Session 0<\/a>. There are a couple of ways to achieve this:\n<\/p>\n<ol>\n<li>\n<h3 style=\"margin-top:30px;\">Run your Utility as a Windows Service<\/h3>\n<p>We recommend using our AlwaysUp application to run your chosen utility as a Windows Service. If you are using an AutoIt script, set it up to run periodically, <a href=\"\/blog\/alwaysup\/how-to-run-your-application-every-minute\/\">perhaps once every minute<\/a>. For Buzof, which should be started once and kept running continuously, any service wrapper (such as <a href=\"\/WindowsServices\/FAQ.html#WhatIsSrvany\">Microsoft&#8217;s Srvany<\/a>) will perform the basic job.<\/p>\n<\/li>\n<li>\n<h3 style=\"margin-top:30px;\">Run your Utility with the Task Scheduler<\/h3>\n<p>Setup a basic scheduled task to start your solution. It will run entirely in Session 0.<\/p>\n<\/li>\n<\/ol>\n<p>Note that you can also launch your utility manually in Session 0 using Microsoft&#8217;s <a href=\"http:\/\/www.coretechnologies.com\/WindowsServices\/FAQ.html#StartInSession0\">PsExec<\/a> command line tool.\n<\/p>\n<p><b>Best of luck keeping your Windows Services operating 24&#215;7, without annoying interruptions!<\/b><\/p>\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\/servicetray\/start-automatically-at-login\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"How do I Start ServiceTray when I Login to Windows?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/windows-10-problem-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\">How do I Start ServiceTray when I Login to Windows?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/sc-service-fails-to-start\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: I created a Windows Service with SC. Why won&#039;t it Start?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/sc-service-fails-to-start-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\">Q&amp;A: I created a Windows Service with SC. Why won&#039;t it Start?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/samss\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Essential Windows Services: Security Accounts Manager \/ SamSs\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/security-accounts-manager-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\">Essential Windows Services: Security Accounts Manager \/ SamSs<\/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>Why Windows Services Should Avoid Showing Popups\/Dialog Boxes Unlike a regular application (like Microsoft Word) that you launch from a desktop icon and actively work with to accomplish a specific task, a Windows Service is designed to start when your &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/dismiss-popups-dialog-boxes\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2369,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[35,48,91,153,164,196],"class_list":["post-2280","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-services","tag-autoit","tag-buzof","tag-interactive-services","tag-session-0-isolation","tag-task-scheduler","tag-windows-services-2"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/2280","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=2280"}],"version-history":[{"count":3,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/2280\/revisions"}],"predecessor-version":[{"id":11246,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/2280\/revisions\/11246"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/2369"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=2280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=2280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=2280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}