{"id":70643,"date":"2005-01-17T09:51:00","date_gmt":"2005-01-17T09:51:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/01\/17\/how-can-i-change-the-legal-warning-message-using-a-script\/"},"modified":"2005-01-17T09:51:00","modified_gmt":"2005-01-17T09:51:00","slug":"how-can-i-change-the-legal-warning-message-using-a-script","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-change-the-legal-warning-message-using-a-script\/","title":{"rendered":"How Can I Change the Legal Warning Message Using a Script?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I use a script to change the legal warning message on a computer?<BR><BR>&#8212; RB<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, RB. As you all probably know, when you press <B>Ctrl-Alt-Delete<\/B> to log on to Windows, you\u2019re typically presented with a logon box. You type your user name, domain, and password in the box, click <B>OK<\/B>, and away you go. <\/P>\n<P>However, Windows includes a provision for displaying a legal message dialog box after you press <B>Ctrl-Alt-Delete<\/B> but before you\u2019re presented with the logon box. This gives you an opportunity to present users with a legal disclaimer of some kind. If these users click <B>OK<\/B> and proceed to logon, then they\u2019ve agreed to abide by whatever rules and regulations you specified in your disclaimer. In turn, that gives you at least some legal protection against any kind of \u2026 mischief \u2026 the user might engage in while logged-on to your computer.<\/P>\n<P>Typically the caption and message text for the legal warning dialog box is controlled using Group Policy; that makes it easy to apply that warning message to every computer in your domain. On the other hand, you might not want to use Group Policy; you might not be able to use Group Policy (after all, Group Policy works only if you\u2019re running Active Directory); or you might want to use different messages for different computers. In cases such as those, scripts might be just what the doctor ordered.<\/P>\n<P>Well, assuming the doctor is Dr. Scripto, of course.<\/P>\n<P>As it turns out, <B>LegalNoticeCaption<\/B> and <B>LegalNoticeText<\/B> are a pair of registry values found in the HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon portion of the registry. To enable a legal warning message on a computer, all you have to do is configure values for these two items. And you can do that using a script very similar to this:<\/P><PRE class=\"codeSample\">Const HKEY_LOCAL_MACHINE = &amp;H80000002\nstrComputer = &#8220;.&#8221;<\/p>\n<p>Set objReg=GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyPath = &#8220;SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon&#8221;\nstrValueName = &#8220;LegalNoticeCaption&#8221;\nstrValue = &#8220;Fabrikam, Inc. Legal Notice&#8221;\nobjReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue<\/p>\n<p>strKeyPath = &#8220;SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon&#8221;\nstrValueName = &#8220;LegalNoticeText&#8221;\nstrValue = &#8220;By logging on to this computer you agree to abide by the &#8221;\nstrValue = strValue &amp; &#8220;computer usage rules and regulations of Fabrikam, Inc.&#8221;\nstrValue = strValue &amp; vbCrLf &amp; vbCrLf\nstrValue = strValue &amp; &#8220;For more information, phone (425)-555-1289.&#8221;\nobjReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue\n<\/PRE>\n<P>The preceding script sets the caption (LegalNoticeCaption) of the warning message dialog box to <B>Fabrikam, Inc. Legal Notice<\/B>. It then sets the actual message itself (LegalNoticeText) to this:<\/P>\n<P><B>By logging on to this computer you agree to abide by the computer usage rules and regulations of Fabrikam, Inc.<\/B><\/P>\n<P><B>For more information, phone (425)-555-1289.<\/B><\/P>\n<P>You might notice in the script that we use several lines of code to configure the message. We don\u2019t necessarily have to do that; we could instead use one sprawling line of code that spanned several screens. Code like that is difficult to read and to modify, however, so we configured our message in several steps as opposed to one big step. To begin with, we set the value of a variable named strValue using this line of code:<\/P><PRE class=\"codeSample\">strValue = &#8220;By logging on to this computer you agree to abide by the &#8221;\n<\/PRE>\n<P>Now, take a look at the very next line of code in the script:<\/P><PRE class=\"codeSample\">strValue = strValue &amp; &#8220;computer usage rules and regulations of Fabrikam, Inc.&#8221;\n<\/PRE>\n<P>As you can see, we now assign strValue the existing value of strValue (By logging on to this computer you agree to abide by the) <I>plus<\/I> this: computer usage rules and regulations of Fabrikam, Inc. Our variable strValue now equals to this:<\/P>\n<P><B>By logging on to this computer you agree to abide by the computer usage rules and regulations of Fabrikam, Inc.<\/B><\/P>\n<P>We then tack on a couple of carriage return-linefeeds (using the VBScript constant vbCrLf) and then the last line of the message. With the entire message now stashed in the variable strName, we\u2019re ready to call the SetStringValue method and write this new value to the registry.<\/P>\n<P>Now, what if you change your mind and decide you don\u2019t want to use a warning message after all? If that happens just use a script and set both LegalNoticeCaption and LegalNoticeText to empty strings. Thus:<\/P><PRE class=\"codeSample\">Const HKEY_LOCAL_MACHINE = &amp;H80000002\nstrComputer = &#8220;.&#8221;<\/p>\n<p>Set objReg=GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyPath = &#8220;SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon&#8221;\nstrValueName = &#8220;LegalNoticeCaption&#8221;\nstrValue = &#8220;&#8221;\nobjReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue<\/p>\n<p>strKeyPath = &#8220;SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon&#8221;\nstrValueName = &#8220;LegalNoticeText&#8221;\nstrValue = &#8220;&#8221;\nobjReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue\n<\/PRE>\n<P>By the way, if you\u2019re interested in learning a bit more about manipulating registry values using scripts, watch the <A href=\"http:\/\/msevents.microsoft.com\/cui\/eventdetail.aspx?EventID=1032268755&amp;culture=en-US\"><B>Things the Scripting Guys Never Told You<\/B><\/A> webcast.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I use a script to change the legal warning message on a computer?&#8212; RB Hey, RB. As you all probably know, when you press Ctrl-Alt-Delete to log on to Windows, you\u2019re typically presented with a logon box. You type your user name, domain, and password in the box, click OK, [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[31,26,3,5],"class_list":["post-70643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-operating-system","tag-registry","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I use a script to change the legal warning message on a computer?&#8212; RB Hey, RB. As you all probably know, when you press Ctrl-Alt-Delete to log on to Windows, you\u2019re typically presented with a logon box. You type your user name, domain, and password in the box, click OK, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/70643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=70643"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/70643\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=70643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=70643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=70643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}