{"id":10532,"date":"2019-07-30T11:43:56","date_gmt":"2019-07-30T11:43:56","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=10532"},"modified":"2019-08-03T19:17:08","modified_gmt":"2019-08-03T19:17:08","slug":"trigger-launch-program-script-connecting-to-specific-network","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/trigger-launch-program-script-connecting-to-specific-network\/","title":{"rendered":"Trigger a Program Upon Connecting to a Specific Network in Windows"},"content":{"rendered":"<p>Depending upon the network you&#8217;re connected to, you may want to run certain tasks. For instance, when you&#8217;re connected to a specific network &#8212; e.g., home network &#8212; you may want to assign a <a href=\"https:\/\/www.winhelponline.com\/blog\/stop-windows-10-change-default-printer-automatically\/\">different printer<\/a> as the default, using command-line or script. This is especially needed in Windows 10 where the &#8220;location-aware printing&#8221; feature has been removed.<\/p>\n<p>Or, you may need to <a href=\"https:\/\/www.winhelponline.com\/blog\/how-to-use-the-file-history-feature-in-windows-8-and-10\/\">run a backup task<\/a>, or set the <a href=\"https:\/\/www.winhelponline.com\/blog\/how-to-change-the-office-365-2016-default-save-folder\/\">default save location<\/a> in your Office apps to local documents instead of OneDrive when connected to a home network. Some users would want to turn on their VPN software upon connecting to a particular network.<\/p>\n<p><!--more--><\/p>\n<p>Windows allows you to accomplish the task using event trigger and Task Scheduler. When you connect to a network, Windows logs the action to the <code>Microsoft-Windows-NetworkProfile\/Operational<\/code> event log. The event ID is <code>10000<\/code> represents &#8220;connected&#8221; event and <code>10001<\/code> represents &#8220;disconnected&#8221; event. Here is a sample event.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10534\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/trigger-run-program-network-connection-1.png\" alt=\"trigger launch program when connecting to a specific network connection\" width=\"700\" height=\"475\" \/><\/p>\n<pre>Log Name: Microsoft-Windows-NetworkProfile\/Operational\r\nSource: Microsoft-Windows-NetworkProfile\r\nDate: 7\/30\/2019 2:34:33 PM\r\nEvent ID: 10000\r\nTask Category: None\r\nLevel: Information\r\nKeywords: (35184372088832),(32)\r\nUser: LOCAL SERVICE\r\nComputer: DESKTOP-JKJ4G5Q\r\nDescription:\r\nNetwork Connected\r\nName: Ramesh\r\nDesc: Ramesh\r\nType: Unmanaged\r\nState: Connected\r\nCategory: Private\r\n\r\nEvent Xml:\r\n&lt;Event xmlns=\"http:\/\/schemas.microsoft.com\/win\/2004\/08\/events\/event\"&gt;\r\n&lt;System&gt;\r\n&lt;Provider Name=\"Microsoft-Windows-NetworkProfile\" Guid=\"{fbcfac3f-8459-419f-8e48-1f0b49cdb85e}\" \/&gt;\r\n&lt;EventID&gt;10000&lt;\/EventID&gt;\r\n&lt;Version&gt;0&lt;\/Version&gt;\r\n&lt;Level&gt;4&lt;\/Level&gt;\r\n&lt;Task&gt;0&lt;\/Task&gt;\r\n&lt;Opcode&gt;0&lt;\/Opcode&gt;\r\n&lt;Keywords&gt;0x4000200000000020&lt;\/Keywords&gt;\r\n&lt;TimeCreated SystemTime=\"2019-07-30T09:04:33.524213200Z\" \/&gt;\r\n&lt;EventRecordID&gt;3216&lt;\/EventRecordID&gt;\r\n&lt;Correlation \/&gt;\r\n&lt;Execution ProcessID=\"2388\" ThreadID=\"4596\" \/&gt;\r\n&lt;Channel&gt;Microsoft-Windows-NetworkProfile\/Operational&lt;\/Channel&gt;\r\n&lt;Computer&gt;DESKTOP-JKJ4G5Q&lt;\/Computer&gt;\r\n&lt;Security UserID=\"S-1-5-19\" \/&gt;\r\n&lt;\/System&gt;\r\n&lt;EventData&gt;\r\n<strong>&lt;Data Name=\"Name\"&gt;Ramesh&lt;\/Data&gt;<\/strong>\r\n&lt;Data Name=\"Description\"&gt;Ramesh&lt;\/Data&gt;\r\n&lt;Data Name=\"Guid\"&gt;{f6435db3-31b3-43ea-8d7f-4c28208a954d}&lt;\/Data&gt;\r\n&lt;Data Name=\"Type\"&gt;0&lt;\/Data&gt;\r\n&lt;Data Name=\"State\"&gt;1&lt;\/Data&gt;\r\n&lt;Data Name=\"Category\"&gt;1&lt;\/Data&gt;\r\n&lt;\/EventData&gt;\r\n&lt;\/Event&gt;<\/pre>\n<p>The bold line above represents the network connection, in this case, the network name or the SSID is <code>Ramesh<\/code>.<\/p>\n<p>Now, let&#8217;s create an event trigger for event ID 10000 Microsoft-Windows-NetworkProfile\/Operational event. The event trigger scheduled task will launch a program or script.<\/p>\n<p>You can use the <strong>Attach Task To This Event&#8230;<\/strong> option in the event&#8217;s right-click menu in Event Viewer to create an event trigger task. Alternately, you can follow these Task Scheduler steps.<\/p>\n<h2>Launch a Program or Script when Connected to a Specific Network<\/h2>\n<ol>\n<li>Open Task Scheduler and click <strong>Create Task&#8230;<\/strong><\/li>\n<li>Assign a name and description for the task.<\/li>\n<li>Select the Triggers tab, and click <strong>New<\/strong><\/li>\n<li>Select <strong>On an event<\/strong><\/li>\n<li>In the Log: dropdown box, select\u00a0<strong>Microsoft-Windows-NetworkProfile\/Operational<\/strong><\/li>\n<li>In the Source: select <strong>NetworkProfile<\/strong><\/li>\n<li>In the Event ID: field, type <code>10000<\/code>, and click OK<\/li>\n<li>In the Actions tab, click New.<\/li>\n<li>In the Program\/Script: name, type the program or script file name you want to run when your device connects to a specific network. For example, you may choose to run a custom VBScript that executes some commands upon connecting to that network. To run a VBScript, choose <code>wscript.exe<\/code> in the <strong>Program\/Script:<\/strong> field, and the name of the script (.vbs file) in the <strong>Add arguments:<\/strong> field.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10533\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/trigger-run-program-network-connection-2.png\" alt=\"trigger launch program when connecting to a specific network connection\" width=\"454\" height=\"500\" \/><\/li>\n<li>Click OK.<\/li>\n<li>Select the Conditions tab, and enable Start only if the following network connection is available.<\/li>\n<li>Select the network or SSID from the list so that the scheduled task will trigger when you connect to the specific network.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10536\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/trigger-run-program-network-connection-3.png\" alt=\"trigger launch program when connecting to a specific network connection\" width=\"633\" height=\"604\" \/><\/li>\n<li>If the program or script requires administrator privileges to run correctly, make sure to enable the <strong>Run with highest privileges<\/strong> checkbox, and click OK.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10535\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/trigger-run-program-network-connection-4.png\" alt=\"trigger launch program when connecting to a specific network connection\" width=\"632\" height=\"480\" \/><\/li>\n<li>Click OK. The event trigger task is now created.<\/li>\n<\/ol>\n<h3>Task not triggered on network condition in Windows 10?<\/h3>\n<p>In Windows 10 Anniversary Update and higher, the task may not get triggered if a network condition is set in the GUI. This bug still remains in Windows 10 v1903. In some systems, setting a network condition causes the error <a href=\"https:\/\/www.winhelponline.com\/blog\/task-scheduler-service-is-not-available-will-attempt-to-reconnect\/\">Task Scheduler service is not available. Task Scheduler will attempt to reconnect to it.<\/a><\/p>\n<p>To workaround the problem, disable all network conditions and use the following custom trigger method.<\/p>\n<ol>\n<li>Double-click the newly created task.<\/li>\n<li>Select the Conditions tab, and uncheck <strong>Start only if the following network connection is available<\/strong>.<\/li>\n<li>Select the Triggers tab, and click Edit.<\/li>\n<li>In the Edit Trigger dialog, click Custom, and click New Event Filter&#8230;<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10537\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/trigger-run-program-network-connection-5.png\" alt=\"trigger launch program when connecting to a specific network connection\" width=\"591\" height=\"215\" \/><\/li>\n<li>In the New Event Filter, select the XML tab, and enable <strong>Edit query manually<\/strong>.<\/li>\n<li>Click Yes, when you see the message: <strong><em>If you choose to manually edit the query, you will no longer be able to modify the query using the controls on the Filter tab. Would you like to continue?<\/em><\/strong><\/li>\n<li>Paste the following custom XML trigger markup in the text box.\n<pre>&lt;QueryList&gt;\r\n&lt;Query Id=\"0\" Path=\"System\"&gt;\r\n&lt;Select Path=\"Microsoft-Windows-NetworkProfile\/Operational\"&gt;\r\n*[System[(EventID=10000)]] and *[EventData[(Data[@Name=\"Name\"]=\"<strong>TYPE-YOUR-SSID<\/strong>\")]]\r\n&lt;\/Select&gt;\r\n&lt;\/Query&gt;\r\n&lt;\/QueryList&gt;<\/pre>\n<p><em>If need to trigger the task when you connect to an active directory domain network, use the domain name instead of the SSID.<\/em><\/li>\n<li>Click OK, OK.<\/li>\n<\/ol>\n<p>Similarly, you may create another event trigger scheduled task that runs when you connect to your office network, which in turn launches a custom VBScript, a program or a batch file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Depending upon the network you&#8217;re connected to, you may want to run certain tasks. For instance, when you&#8217;re connected to a specific network &#8212; e.g., home network &#8212; you may want to assign a different printer as the default, using command-line or script. This is especially needed in Windows 10 where the &#8220;location-aware printing&#8221; feature &#8230; <a title=\"Trigger a Program Upon Connecting to a Specific Network in Windows\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/trigger-launch-program-script-connecting-to-specific-network\/\" aria-label=\"Read more about Trigger a Program Upon Connecting to a Specific Network in Windows\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[8],"tags":[],"class_list":["post-10532","post","type-post","status-publish","format-standard","hentry","category-windows-10"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":20074,"url":"https:\/\/www.winhelponline.com\/blog\/automatic-trigger-start-manual-services-windows\/","url_meta":{"origin":10532,"position":0},"title":"Automatic (Trigger Start) and Manual (Trigger Start) Differences","author":"Ramesh","date":"November 28, 2020","format":false,"excerpt":"The Services MMC shows the service names, their current status, and startup type. Most of you know about the Automatic, Automatic (Delayed Start), and Manual startup types. Automatic - Starts the services at system startup. Automatic (Delayed start) - Starts the service after the system has finished booting and after\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"trigger start services explained","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2020\/11\/wuauserv-trigger-start-gpedit.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2020\/11\/wuauserv-trigger-start-gpedit.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2020\/11\/wuauserv-trigger-start-gpedit.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1195,"url":"https:\/\/www.winhelponline.com\/blog\/windows-8-services-default-startup-type\/","url_meta":{"origin":10532,"position":1},"title":"Windows 8 Services Configuration Default Startup Type","author":"Ramesh","date":"October 27, 2012","format":false,"excerpt":"Windows 8 Services configuration defaults are listed here. Has your services configuration changes gone awry and not sure about the default settings? This list might benefit some users, especially for the tweakers and breakers :)Name Startup TypeLog On AsActiveX Installer (AxInstSV) Manual Local System Application Experience Manual (Trigger Start) Local\u2026","rel":"","context":"In &quot;Windows 8&quot;","block_context":{"text":"Windows 8","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-8\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":75146,"url":"https:\/\/www.winhelponline.com\/blog\/defender-definitions-update-frequency\/","url_meta":{"origin":10532,"position":2},"title":"How to Change Microsoft Defender Definitions Update Frequency","author":"Ramesh","date":"May 12, 2024","format":false,"excerpt":"Microsoft Malware Protection Center releases security intelligence updates (a.k.a, definition updates) every 3-4 hours to update the virus definitions. However, your system may not automatically install every security intelligence update. Windows Update automatically installs the Defender security intelligence update once per day. It lets you manually check for updates and\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"defender updates - windows update","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/05\/wu-defender-update.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/05\/wu-defender-update.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/05\/wu-defender-update.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4728,"url":"https:\/\/www.winhelponline.com\/blog\/create-shortcut-open-task-manager-startup-tab-directly\/","url_meta":{"origin":10532,"position":3},"title":"How to Open Task Manager to a Specific Tab Directly","author":"Ramesh","date":"December 2, 2016","format":false,"excerpt":"Task Manager opens to Processes tab by default in Windows 8 and 10. If you want it to open to the Startup tab directly, this article tells you how to do it. Windows 10 v1903 Task Manager update In version 1903 and higher, you can set a default tab in\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"task manager default tab","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/12\/task-manager-default-tab.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2172,"url":"https:\/\/www.winhelponline.com\/blog\/wmp-rip-location-is-stuck-empty-change-fix\/","url_meta":{"origin":10532,"position":4},"title":"Windows Media Player Rip Location is Stuck. How to Fix it?","author":"Ramesh","date":"March 18, 2016","format":false,"excerpt":"Summary: The \"Rip Music\" tab in Windows Media Player Options dialog shows up an empty location, and the Change button doesn't work. User is unable to change or set the default Rip folder location. When the folder that was last set as the default Rip location is missing, Windows Media\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/w10\/wmp-rip-empty-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1405,"url":"https:\/\/www.winhelponline.com\/blog\/windows-10-default-services-configuration\/","url_meta":{"origin":10532,"position":5},"title":"Windows 10 Default Services Configuration and Permissions","author":"Ramesh","date":"January 1, 2016","format":false,"excerpt":"The Windows 10 Services configuration defaults are provided on this page. The settings below are gathered from a Windows 10 Pro PC (clean install, rather than upgrade). Last updated on April 27, 2024 - Windows 10 Pro v22H2 is the current version as of this revision. The Service permission (SDDL\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/10532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=10532"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/10532\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=10532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=10532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=10532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}