{"id":89,"date":"2006-05-08T07:29:00","date_gmt":"2006-05-08T14:29:00","guid":{"rendered":"http:\/\/www.jasemccarty.com\/blog\/2006\/05\/vbs-nic-show-iconpower-mgt-script.html"},"modified":"2006-05-08T07:29:00","modified_gmt":"2006-05-08T14:29:00","slug":"vbs-nic-show-iconpower-mgt-script","status":"publish","type":"post","link":"https:\/\/www.jasemccarty.com\/blog\/vbs-nic-show-iconpower-mgt-script\/","title":{"rendered":"VBS: NIC Show Icon\/Power Mgt Script"},"content":{"rendered":"<div style=\"font-family:arial;\"><span class=\"659060314-08052006\"><span style=\"font-size:85%;\">Here&#8217;s script that I wrote (and probably borrowed some of it) to turn all nics&#8217; icons on, and disable power management for them. It only looks at nics with IP enabled. <\/span><\/span><\/div>\n<div style=\"font-family:arial;\"><span class=\"659060314-08052006\"><span style=\"font-size:85%;\"> <\/span><\/span><\/div>\n<div style=\"font-family:arial;\"><span class=\"659060314-08052006\"><span style=\"font-size:85%;\">You can also download it <strong><a href=\"http:\/\/www.jasemccarty.com\/scripts\/nicmod_vbs.txt\">here<\/a><\/strong>. <\/span><\/span><\/div>\n<div style=\"font-family:arial;\"><span class=\"659060314-08052006\"><span style=\"font-size:85%;\">(Just make sure you rename it to nicmod.vbs, or something similar)<\/span><\/span><\/div>\n<p><span class=\"659060314-08052006\"><span style=\"font-family:Arial;font-size:85%;\"> <\/span><\/span><\/p>\n<blockquote><p>&#8216;************************************************************************<br \/>\n&#8216;* VBS Script to:<br \/>\n&#8216;* Enable\/Disable showing the icon in your system tray for connected NICs<br \/>\n&#8216;* Enable\/Disable Power Management for Connected NICs<br \/>\n&#8216;*<br \/>\n&#8216;* 8 MAY 06 \u2013 Jase McCarty<br \/>\n&#8216;************************************************************************<\/p>\n<p>&#8216;Let\u2019s setup our variables<br \/>\nConst HKLM = &amp;H80000002 &#8216;HKEY_LOCAL_MACHINE info for registry writes<br \/>\nDim objReg &#8216;Registry Object<br \/>\nDim objWMIService &#8216;WMI Service Object<br \/>\nDim arrayNetCards &#8216;Array of all connected NICs<br \/>\nDim objNetCard &#8216;A specific NIC<br \/>\nDim strNICguid &#8216;<br \/>\nDim strShowNicKeyName &#8216;Key Specific to the Network Adapters in CurrentControlSet<br \/>\nDim strShowNicKeyName001 &#8216;Key Specific to the Network Adapters in ControlSet001<br \/>\nDim strPnPCapabilitesKeyName &#8216;Key Specific to the Network Adapters in CurrentControlSet<br \/>\nDim strPnPCapabilitesKeyName001 &#8216;Key Specific to the Network Adapters in ControlSet001<br \/>\nDim strComputer &#8216;Name of computer to modify<\/p>\n<p>&#8216;You will have to reboot the system for the settings to take effect, or you could put it in a group policy to automatically run when a system performs a shutdown.<br \/>\nstrComputer = &#8220;.&#8221; &#8216;Period = local computer<\/p>\n<p>strShowNicKeyName = &#8220;SYSTEMCurrentControlSetControlNetwork{4D36E972-E325-11CE-BFC1-08002BE10318}&#8221;<br \/>\nstrShowNicKeyName001 = &#8220;SYSTEMControlSet001ControlNetwork{4D36E972-E325-11CE-BFC1-08002BE10318}&#8221;<br \/>\nstrPnPCapabilitiesKeyName = &#8220;SYSTEMCurrentControlSetControlClass{4D36E972-E325-11CE-BFC1-08002bE10318}&#8221;<br \/>\nstrPnPCapabilitiesKeyName001 = &#8220;SYSTEMControlSet001ControlClass{4D36E972-E325-11CE-BFC1-08002bE10318}&#8221;<\/p>\n<p>ShowNicdwValue = 1<br \/>\n&#8216;1 for ON, 0 for OFF<\/p>\n<p>PnPdwValue = 56<br \/>\n&#8217;56 to disable &#8220;Allow the computer to turn off this device to save power.&#8221;<\/p>\n<p>&#8217;48 to enable &#8220;Allow the computer to turn off this device to save power.&#8221;<\/p>\n<p>&#8217;32 to enable &#8220;Allow the computer to turn off this device to save power.&#8221;<br \/>\n&#8216; and enable &#8220;Allow this device to bring the computer out of standby.&#8221;<\/p>\n<p>&#8216;288 to enable &#8220;Allow the computer to turn off this device to save power.&#8221;<br \/>\n&#8216; and enable &#8220;Allow this device to bring the computer out of standby.&#8221;<br \/>\n&#8216; and enable &#8220;Only allow management stations to bring the computer out of standby.&#8221;<\/p>\n<p>On Error Resume Next<br \/>\nSet objReg = GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}!\\&#8221; &amp; strComputer &amp; &#8220;rootdefault:StdRegProv&#8221;)<br \/>\nSet objWMIService = GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}!\\&#8221; &amp; strComputer &amp; &#8220;rootcimv2&#8221;)<\/p>\n<p>&#8216;Look for the NICs that have IP enabled<br \/>\nSet arrayNetCards = objWMIService.ExecQuery (&#8220;Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True&#8221;)<\/p>\n<p>&#8216;Make changes on the NICs that have IP enabled<br \/>\nFor Each objNetCard in arrayNetCards<\/p>\n<p>strNICguid = objNetCard.SettingID &#8216;Get the GUID of the NIC<br \/>\nstrDeviceID = Mid(objNetCard.Caption,6,4) &#8216;Get the DeviceID of the NIC<\/p>\n<p>&#8216;Change the &#8220;Show icon in notification area when connected value&#8221;<br \/>\nobjReg.SetDWORDValue HKLM, strShowNicKeyName &amp; strNICguid &amp; &#8220;Connection&#8221;, &#8220;ShowIcon&#8221;, ShowNicdwValue<br \/>\nobjReg.SetDWORDValue HKLM, strShowNicKeyName001 &amp; strNICguid &amp; &#8220;Connection&#8221;, &#8220;ShowIcon&#8221;, ShowNicdwValue<\/p>\n<p>&#8216;Change the Power Management Values<br \/>\nobjReg.SetDWORDValue HKLM, strPnPCapabilitiesKeyName &amp; strDeviceID &amp; &#8220;&#8221;,&#8221;PnPCapabilities&#8221;,PnPdwValue<br \/>\nobjReg.SetDWORDValue HKLM, strPnPCapabilitiesKeyName001 &amp; strDeviceID &amp; &#8220;&#8221;,&#8221;PnPCapabilities&#8221;,PnPdwValue<br \/>\nNext<\/p>\n<p>Set objReg = Nothing<\/p>\n<p>Set objWMIService = Nothing<br \/>\n&#8216;*** END OF SCRIPT ***<\/p><\/blockquote>\n<p><span class=\"659060314-08052006\" style=\"font-size:100%;\"><span style=\"font-family:Arial;\">You could also modify this script to take a list of computers, and make the changes on all of them.<\/span><\/span><br \/>\n<span class=\"659060314-08052006\" style=\"font-size:100%;\"><\/span><br \/>\n<span style=\"font-family:Arial;font-size:100%;\">E<span class=\"659060314-08052006\">njoy.<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s script that I wrote (and probably borrowed some of it) to turn all nics&#8217; icons on, and disable power management for them. It only &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-vbs"],"_links":{"self":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/comments?post=89"}],"version-history":[{"count":0,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}