In this "Instructable" I'll be showing you how to make a message box in Notepad using VBScript Coding.

Please Note: This is a completely harmless project and if something DOES go wrong, I will not be help responsible.

Step 1: Step One

First thing to do is locate your Notepad.exe.
This application is on every windows computer OS and can be used for loads of interesting things.
Notepad.exe is normally located in Start Menu>All programs>Accessories

Step 2: Step Two: the Code.

For this next bit, it's fairly simple, because I do all the work.

x=msgbox("Your Text Here" ,0, "Your Title Here")

Make sure that the " is included in the text and replace the Your Text Here and Your Title Here. But don't change anything elese!

Advanced users can change something else.
  • 0 =OK button only
  • 1 =OK and Cancel buttons
  • 2 =Abort, Retry, and Ignore buttons
  • 3 =Yes, No, and Cancel buttons
  • 4 =Yes and No buttons
  • 5 =Retry and Cancel buttons
  • 16 =Critical Message icon
  • 32 =Warning Query icon
  • 48 = Warning Message icon
  • 64 =Information Message icon
  • 0 = First button is default
  • 256 =Second button is default
  • 512 =Third button is default
  • 768 =Fourth button is default
  • 0 =Application modal (the current application will not work until the user responds to the message box)
  • 4096 =System modal (all applications wont work until the user responds to the message box)
Change the "0" with any of these numbers above.

Step 3: Step Three: the Saving

Now for this bit, you would think that this is easy, but it's not as simple as Save As.

When you have finished the code, go to Save As and save it as: What You Want To Call It.vbs
At the end of the name, make sure that .vbs goes at the end and safe it anywhere.

Step 4: Step Four: Lets Test It!

Now that we have completed the following steps, lets test it. Locate your safe file and dubble-click it. Lets see what the outcome was.

Step 5: Outcome.

The outcome of todays lesson was:

Your learned how Notepad.exe can become a powerfull scripting program
How to make a message Box
The values of Message Box's to make them look convincing.

Thank you for reading this lesson

<p>Hello. I've been stuck on what i seem as a noob problem. What i have been trying to make when you press okay in a message box it opens a program. I know my code is horrible but its what i got. If anyone can help please do. </p><p>(if there is anyone on here)</p><p>x=msgbox(&quot;Your Text Here&quot; ,vbOKOnly+vbCritical, &quot;Your Title Here&quot;)</p><p>Select Case result</p><p>Set WSHShell = WScript.CreateObject(&quot;WScript.Shell&quot;)</p><p>WSHShell.Run &quot;1.bat&quot;</p><p>End Select</p><p>____</p><p>thats the code. Again- I'm stuck so far.</p>
<p>How do you make custom buttons?</p>
&nbsp;Nice work but do you know how to make it so that if they click &quot;no&quot; it simply opens the message box again?
<p>do</p><p>X=msgbox(&quot;Yes will close this window.&quot;,vbYesNo+vbCritical,&quot;Title&quot;)</p><p>if X=vbYes then</p><p>loop</p><p>end if</p>
<p>That is the script, include the do.</p>
&nbsp;yes, and also, there is a much easier way to make a msg box, open notepad, type in: msg * your text here &nbsp;Voila!! i am not dissing the file in any way, just a suggestion for easier work.&nbsp;
<p>This works perfectly for making the simple (just &quot;OK&quot; reminder) message box I need, but can anyone tell me how to make the message activate? I specifically want the msgbox I created to pop-up when a general folder is opened. Can't seem to find a way to &quot;activate&quot; the msgbox in the folder's settings...</p>
<p>You would have to open a folder using a script to accomplish this, something like this:</p><p>x=msgbox(&quot;Would you like to open the Windows folder?&quot; ,4, &quot;Question:&quot;)</p><p>If x = vbNo Then Wscript.Quit(0)</p><p>If x = VbYes Then</p><p>Set WshShell = CreateObject(&quot;WScript.Shell&quot;)</p><p>X = WshShell.run(&quot;cmd /c explorer.exe &quot;&quot;C:\Windows&quot;&quot;&quot;,0, true)</p><p>End If</p>
Thank you for taking the time to reply. I'm an extreme novice with this stuff, but don't think this is what I was looking for. Let me know if I'm mistaken:<br>- I copied/pasted everything you put into Notepad and saved as a .vbs file. Then when I click on that file, it asks if I want to open the Windows folder (and gives me a yes or no options). When I click &quot;yes&quot; it opens the folder C:/Windows. This all sounds like how the example was designed to work.<br>- However, what I was hoping for was a way to show a pop up message WHEN I CLICK ON A FOLDER. An example would be if when I click on a &quot;Pictures&quot; folder I created, I want a pop up box to trigger and say something like &quot;Reminder:&quot; and &quot;Remember to put new pictures on external hard drive&quot; and then just have an &quot;OK&quot; option. That way, I'll remember to save my pics to my external hard drive every time I click on the &quot;Pictures&quot; folder. This is just an example, I really want to use if for work where I have customer's folders that contact past proposals, reports, documents...and a few of them require certain things like &quot;must include sales tax on proposals,&quot; or &quot;This customer has 10% Discount on all orders&quot; - so I want everyone in my company to see these kinds of reminders when clicking on their folders in Windows Explorer.<br><br>It sounds like what I want is the other way around from what you said, so while your way lets me click on the VBS file, then click yes to open the example folder, my hope is to swap that around (click on a folder and then have a pop-up box show up to remind me certain things). Maybe some minor tweaking is what is needed.<br><br>Thanks again and if you have an answer to my follow up question, please let me know. Appreciate your help.
<p>Set WshShell=CreateObject(&quot;WScript.Shell&quot;)</p><p>X=WshShell.run(&quot;cmd /c explorer.exe &quot;&quot;&lt;Path to pictures folder&gt;&quot;&quot;&quot;,0, true)</p><p>Y=msgbox(&quot;Remember to put new pictures on external hard drive&quot;,0+64,&quot;Reminder:&quot;)</p><p>That should be what you are looking for. Make a shortcut on your desktop, move the vbs file into the C: drive, right-click the shortcut, click properties, if not already, go to the &quot;Shortcut&quot; tab, click [Change Icon...], find the icon that matches your pictures icon in the File Explorer and click on it, press [OK], on the &quot;Properties&quot; menu press [Apply], then press [OK].</p><p>I hope this is what you wanted...</p><p><br></p><p>-Marshal</p>
<p>What's wrong with this code?</p><p>(Nothing will happen when the Ok button is pressed on the last dialog box)</p><p>X=MsgBox(&quot;Virus detected&quot; &amp; chr(13) &amp; &quot;Scanning is strongly recommended&quot;,1+48,&quot;Windows firewall&quot;) </p><p>x=MsgBox(&quot;Scanning in progress&quot; &amp; chr(13) &amp; &quot;Please wait&quot;, 2+64, &quot;Scanning&quot;)</p><p>X=MsgBox(&quot;Virus removal failed&quot; ,0+16, &quot;Disinfection aborted by the user&quot;)</p><p>X=MsgBox(&quot;Do you wish to allow the virus to be activated?&quot;,4+64,&quot;Elk cloner&quot;)</p><p>x=MsgBox(&quot;Uploading personal information to the server....&quot;&amp;chr(13)&amp;&quot;Please wait&quot;&amp;chr(13)&amp; &quot;Cancelling is not recommended&quot; ,1+64, &quot;Uploading&quot;)</p><p>x=msgbox(&quot;Uploading Failed&quot;&amp;chr(13)&amp;&quot;Do you wish to retry?&quot;,4+16,&quot;Uploading failed&quot;)</p><p>x=msgbox(&quot;Uploading personal information to the server....(Second attempt)&quot;&amp;chr(13)&amp;&quot;Please wait&quot;&amp;chr(13)&amp; &quot;Cancelling is not recommended&quot; ,1+64, &quot;Uploading&quot;)</p><p>x=msgbox(&quot;Uploading Failed&quot;&amp;chr(13)&amp;&quot;Do you wish to retry?&quot;,4+16,&quot;Uploading failed&quot;)</p><p>x=msgbox(&quot;Uploading personal information to the server....(Third attempt)&quot;&amp;chr(13)&amp;&quot;Please wait&quot;&amp;chr(13)&amp; &quot;Cancelling is not recommended&quot; ,1+64, &quot;Uploading&quot;)</p><p>x=msgbox(&quot;Uploading Failed&quot;&amp;chr(13)&amp;&quot;Do you wish to retry?&quot;,4+16,&quot;Uploading failed&quot;)</p><p>x=msgbox(&quot;Uploading personal information to the server....(Forth attempt)&quot;&amp;chr(13)&amp;&quot;Please wait&quot;&amp;chr(13)&amp; &quot;Cancelling is not recommended&quot; ,1+64, &quot;Uploading&quot;)</p><p>x=msgbox(&quot;Uploading Failed&quot;&amp;chr(13)&amp;&quot;Do you wish to retry?&quot;,4+16,&quot;Uploading failed&quot;)</p><p>x=msgbox(&quot;Uploading personal information to the server....(Fifth attempt)&quot;&amp;chr(13)&amp;&quot;Please wait&quot;&amp;chr(13)&amp; &quot;Cancelling is not recommended&quot; ,1+64, &quot;Uploading&quot;)</p><p>set shellobj = CreateObject(&quot;WScript.Shell&quot;)</p><p>shellobj.run &quot;cmd&quot;</p><p>wscript.sleep 1700</p><p>shellobj.sendkeys &quot;s&quot;</p><p>wscript.sleep 300</p><p>shellobj.sendkeys &quot;h&quot;</p><p>wscript.sleep 500</p><p>shellobj.sendkeys &quot;u&quot;</p><p>wscript.sleep 200</p><p>shellobj.sendkeys &quot;t&quot;</p><p>wscript.sleep 1300</p><p>shellobj.sendkeys &quot;d&quot;</p><p>wscript.sleep 200</p><p>shellobj.sendkeys &quot;o&quot;</p><p>wscript.sleep 200</p><p>shellobj.sendkeys &quot;w&quot;</p><p>wscript.sleep 200</p><p>shellobj.sendkeys &quot;n&quot;</p><p>wscript.sleep 1000</p><p>Shellobj.sendkeys &quot; /s&quot;</p><p>wscript.sleep 800</p><p>shellobj.sendkeys &quot;{BACKSPACE}&quot;</p><p>wscript.sleep 500</p><p>shellobj.sendkeys &quot;s&quot;</p><p>wscript.sleep 900</p><p>x=msgbox(&quot;Do you mind pressing the Return key?&quot; ,4+32, &quot;Kindly requesting you&quot;)</p><p>If x = vbNo Then x=msgbox(&quot;How rude?&quot; &amp;chr(13)&amp; &quot;Then, I'll do it myself&quot; ,1, &quot;Rude response received&quot;)</p><p>If x = vbOk Then wscript.sleep 800</p><p>shellobj.sendkeys &quot;{ENTER}&quot;</p><p>If x = vbCancel Then shellobj.sendkeys &quot;{ENTER}&quot;</p><p>If x = VbYes Then wscript.sleep 100</p><p>shellobj.sendkeys &quot;{ENTER}&quot;</p><p>x=msgbox(&quot;Closing command prompt is also rude&quot;&amp;chr(13)&amp;&quot;Would you like to shutdown anyway?&quot; ,1+64, &quot;That's also rude&quot;)</p><p>If x = vbCancel Then</p><p>wscript.sleep 2000</p><p>set shell= CreateObject(&quot;Wscript.Shell&quot;)</p><p>shell.run&quot;shutdown.exe -s -t 30&quot;</p><p>If x = vbOk Then </p><p>wscript.sleep 1000</p><p>set shell= CreateObject(&quot;Wscript.Shell&quot;)</p><p>shell.run&quot;shutdown.exe -s -t 30&quot;</p><p>End If</p><p>End If</p>
<p>I'd like to be able to name the buttons you press, (instead of only having OK, Cancel, Yes, etc.) Is this possible?</p><p>I'd also like to know how to have an outcome according to what someone pressed. (For example if I press OK something different happens than if I press Cancel)</p>
<p>you will need visual basic 2010 to do that Nathan.</p>
<p>You say to do this also it requires VB 10?</p><p>http://www.vbsedit.com/html/f482c739-3cf9-4139-a6af-3bde299b8009.asp</p>
<p>If we can, how do we seperate lines into paragraphs?</p>
<p>You can add line breaks though </p><p>https://www.youtube.com/watch?v=O0q085ruk6M</p>
<p>I am trying to get the script to loop IF and ONLY IF the user selects vbRetry.</p><blockquote>x=msgbox(&quot;Error code: 00x00000&quot; &amp; VbCrLf &amp; &quot;Description: We couldn't handle that request&quot; &amp; VbCrLf &amp; &quot;Details: getLateReplyFromGrumpyCat&quot; ,5+16, &quot;Unexpected Error&quot;)</blockquote><blockquote>If x = vbNo Then Wscript.Quit(0)</blockquote><blockquote>If x = vbRetry Then do loop</blockquote><blockquote>End If</blockquote><p>Please explain what I am doing wrong.</p>
<ul><br><li>0 =Application modal (the current application will not work until the user responds to the message box)</ul><p>how to do this?</p>
<p>between each of the #'s (Which you get in the list) you put + signs like x=msgbox(&quot;Stuff&quot; ,0+64+0+0, &quot;Stuff&quot;). Make sure to do them in order though. Here's a SEPERATED key:</p><p><strong>BUTTONS</strong></p><ul><br><li><strong>0 =OK button only</strong><li><strong>1 =OK and Cancel buttons</strong><li><strong>2 =Abort, Retry, and Ignore buttons</strong><li><strong>3 =Yes, No, and Cancel buttons</strong><li><strong>4 =Yes and No buttons</strong><li><strong>5 =Retry and Cancel buttons</strong></ul><p></p><p><strong>ICONS</strong></p><ul><li><strong>16 =Critical Message icon</strong><li><strong>32 =Warning Query icon</strong><li><strong>48 = Warning Message icon</strong><li><strong>64 =Information Message ico</strong></ul><p><strong><br></strong></p><p><strong>DEFAULT BUTTON</strong></p><ul><li><b>0 = First button is default</b><li><strong>256 =Second button is default</strong><li><strong>512 =Third button is default</strong><li><strong>768 =Fourth button is default</strong></ul><p><strong><br></strong></p><p><strong>PROGRAM SUSPENSION</strong></p><ul><br><li><strong>0 =Application modal (the current application will not work until the user responds to the message box)</strong><li><strong>4096 =System modal (all applications wont work until the user responds to the message box)</strong></ul><p></p>
<p>i want to make the computer shutdown after the message pops up how to do this?</p>
<p>Just type</p><p>set objshell = CreateObject(&quot;WScript.Shell&quot;)</p><p>objshell.Run &quot;shutdown.exe -s&quot; ,0</p>
<p>Well I am no expert, and there is certainly a much easier way of doing this, but I have a command that can do it. After the message box in notepad, paste the following: </p><blockquote>set shellobj = CreateObject(&quot;WScript.Shell&quot;)<br>shellobj.run &quot;cmd&quot;<br>wscript.sleep 100<br>shellobj.sendkeys &quot;shutdown&quot;<br>wscript.sleep 20<br>Shellobj.sendkeys &quot; /s&quot;<br>wscript.sleep 20<br>shellobj.sendkeys [ENTER]</blockquote><p>the first 2 lines just tells the program to run command prompt</p><p>then it says to wait 100 miliseconds, then tells it to write &quot;shutdown&quot;. Then the program waits another 20 ms, then writes &quot; /s&quot;, 20 ms again and then hits enter. If you write: &quot;Shutdown /s&quot; in command prompt and hit enter, it shuts the pc down. (you can change the miliseconds how you want, but I would recommend to put a pause between every step)</p><p>(you can also write: </p><blockquote>wscript.sleep 20<br>Shellobj.sendkeys &quot;cls&quot;<br>wscript.sleep 20<br>shellobj.sendkeys [ENTER]</blockquote><p>at the end to make command prompt close again.</p>
<p>Thanks for your tut :) <br>Where is the mistake?</p><p>I wrote this script myself :)</p><p>Suggestions for improvement</p><p>help me pls</p>
This is a good tutorial but is there a way to have it open another message box?<br>
<p>yes just put another one below it like this:</p><p><strong><em><br></em></strong></p><strong><em>x=msgbox(&quot;Your Text Here&quot; ,0, &quot;Your Title Here&quot;)</em></strong><strong><em>x=msgbox(&quot;Your Text Here&quot; ,0, &quot;Your Title Here&quot;)</em></strong><strong><em>x=msgbox(&quot;Your Text Here&quot; ,0, &quot;Your Title Here&quot;)</em></strong><p><strong><br></strong></p>
<p>I am a beginner but i wan tot try something new .. does anyone know how to add a script while in the program? for ex... user can create their own command! so there is a text box and it asks them do u want to make a command</p><p>and if they say yes it asks what do u need to type to ex.. ur command. then they type it in while it scans throught the </p><p>other commands to see if it is not take... And if it is not taken then it takes them to the next str text and it asks them </p><p>what will it say when the command ex.. and when they type that it they press done</p>
<p>Nice guide!</p><p>Also, this page shows plenty of VBS commands and examples: <a href="http://ss64.com/vb/" rel="nofollow">http://ss64.com/vb/</a></p>
<p>i want to have a .bat file write a temp .vbs with the following code:</p><p>Do</p><p>MsgBox&quot;message&quot;,4096,&quot;Message&quot;</p><p>Loop</p><p>is there a way to embed this?</p>
<p>@echo off</p><p>x=msgbox(&quot;message&quot; ,4096, &quot;Message&quot;) &gt; temp.vbs</p><p>:start</p><p>start temp.vbs</p><p>goto start</p><p>I hope I this was what you ment. </p>
<p>I believe you can do this:</p><p>@echo off</p><p>cd %temp%</p><p>echo do &gt;&gt; temp.vbs</p><p>echo MsgBox&quot;message&quot;,4096,&quot;Message&quot; &gt;&gt; temp.vbs</p><p>echo loop &gt;&gt; temp.vbs</p><p>wscript temp.vbs</p><p>del temp.vbs</p><p>exit</p>
<p>Thanks for teaching me this new skill lol</p>
Oh, I understand... Hmmm, well I have to think about that scenario as far as I know there isn't a solution for what you'd like to do - would you like to have the end user always receive a message when trying to open a given local folder before they save to that folder? You might be able to create a script and have it monitor if two or more instances of explorer.exe proceses are running (one is always running if someone is logged in, but if two or more are open by the same user then display a message. You won't be able to know what folder they opened that easy and after making the script it would be better to make it a 'service' instead of another process, it could be done.) There also MIGHT be a GPO in which you could set rules on folders or particular folders to run a cha script when launched? I've never had that request yet.
christophor or anyone, could you please give an example with more lines. <br> <br>I created a batch file that works fine using the single line text format you gave, but I cannot get it to work with 2 or more lines. Your help would be greatly appreciated. <br> <br>Ultimately, I'd like the .bat file to create the msgbox with title and multiple lines.
<p>The only reason I wouldn't use a Batch file to open a VBS file is because you will see the Command window in the background but if you want to relate VBS to Batch File you can do the following:</p><p>strMB = inputbox(&quot;Please enter your message here:&quot;)</p><p>Set WshShell = CreateObject(&quot;WScript.Shell&quot;)</p><p>WshShell.run &quot;cmd /c @echo msgbox &quot; &amp; &quot;&quot;&quot;&quot; &amp; strMB &amp; &quot;&quot;&quot;&quot; &amp; &quot;,4096,&quot;&quot;VBS2CMD2VBS:&quot;&quot;&gt;C:\Message.vbs&quot;,0, true</p><p>WshShell.run &quot;C:\windows\system32\wscript.exe C:\Message.vbs&quot;,0, false</p><p>Wscript.Quit(0)</p><p>Now what we just did was pass the Variable on to another VBS using the Command line, or in essence a Batch file, you could do the same thing, the 1st script then called the VBS you just made. I am just showing you how complex you can make it and that you can execute anything in VBS that you can from a command line, but you can accomplish the same effect with less code like this:</p><p>strMB = inputbox(&quot;Please enter your message here:&quot;)</p><p>msgbox strMB, 4096, &quot;Message&quot;</p>
<p>I selected option as 4. like Yes and No. But I want an website to open if clicked NO.</p><p>Can you please help?</p>
<p>PrasunU,</p><p>you can use any of these methods (I just think it's good to know different ways that work):</p><p>(A)</p><p>x=msgbox(&quot;Would you like to continue?&quot; ,4, &quot;Question:&quot;)</p><p>If x = vbNo Then MsgBox &quot;You selected 'No'&quot;, 4096, &quot;No:&quot;</p><p>If x = VbYes Then MsgBox &quot;You selected 'Yes'&quot;, 4096, &quot;Yes:&quot;</p><p>(B)</p><p>x=msgbox(&quot;Would you like to continue?&quot; ,4, &quot;Question:&quot;)</p><p>If x = vbNo Then</p><p>MsgBox &quot;You selected 'No'&quot;, 4096, &quot;No:&quot;</p><p>Wscript.Quit(0)</p><p>End If</p><p>If x = VbYes Then</p><p>MsgBox &quot;You selected 'Yes'&quot;, 4096, &quot;Yes:&quot;</p><p>Wscript.Quit(0)</p><p>End If</p><p>(C)</p><p>x=msgbox(&quot;Would you like to continue?&quot; ,4, &quot;Question:&quot;)</p><p>If x = vbNo Then</p><p>MsgBox &quot;You selected 'No'&quot;, 4096, &quot;No:&quot;</p><p>Else</p><p>MsgBox &quot;You selected 'Yes'&quot;, 4096, &quot;Yes:&quot;</p><p>End If</p><p>Wscript.Quit(0)</p>
<p>Attached is my vbs script.</p>
<p>Fantastic. But how do I kill it after 1 second?</p>
<p>Good Question DanG13! Here you go the 5 will kill it in 5 seconds:</p><p>Set WshShell = CreateObject(&quot;WScript.Shell&quot;)</p><p>x = WshShell.Popup(&quot;Would you like to continue?&quot;,5,&quot;Title:&quot;,4)</p><p>If x = vbNo Then Wscript.Quit(0)</p><p>If x = VbYes Then</p><p>'Your script goes here</p><p>msgbox &quot;you selected YES!&quot;, 4096, &quot;Yes&quot;</p><p>End If</p>
<p>How to use this with newline? </p>
<p>The answer is VbCrLf but you will have to add it to what you already like this: &quot;text1&quot; &amp; VbCrLf &amp; &quot;text2&quot; &amp; VbCrLf &amp; &quot;text3&quot;, 0, &quot;title&quot;</p><p>Example:</p><p>x=msgbox(&quot;Would you like to continue?&quot; &amp; VbCrLf &amp; &quot;If you select No, you will see NO&quot; &amp; VbCrLf &amp; VbCrLf &amp; &quot;If you select Yes, you will see YES&quot;,4, &quot;Question:&quot;)</p><p>If x = vbNo Then</p><p>MsgBox &quot;NO&quot;, 4096, &quot;No:&quot;</p><p>Else</p><p>MsgBox &quot;YES&quot;, 4096, &quot;Yes:&quot;</p><p>End If</p>
<p>Did it! Thanks a lot. Now I can make error messages!</p>
<p>It's <strong>VBScript</strong>, A scripting language by <strong>Microsoft</strong>.</p>
<p>Here is something cruel you do to your friends (if you have any)! What this does is loops the box. So when they press &quot;OK&quot;, it closes then opens again. Also, because it's &quot;4096&quot; it sits ontop of everything, just being awkward. Have fun!</p><blockquote>Do</blockquote><blockquote>MsgBox&quot;Just here to be awkward!&quot;,4096,&quot;Troll v6.;</blockquote><blockquote>Loop</blockquote>
<p>Don't put &gt;&quot;msgbox.vbs in the actual notepad, thats what you save it as, what I do is paste this MsgBox(&quot; &quot;,0+0,&quot; &quot;) but of coarse there are no spaces in the final copy, then I just fill it in</p>
<p>um... yeah you got an error didn't you?</p><p>try this and then you will not have an error...</p><p><em>x=msgbox (&ldquo;whatever you want message box to say here&rdquo; ,0, &rdquo;title here&rdquo;) <br>&gt; &ldquo;msgbox.vbs&rdquo;</em></p>
<p>no, thats an error in a command line, you should had an error on one of your commands</p>

About This Instructable




More by Jack.Miller:How to: Make a message box using VBScript 
Add instructable to: