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>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.
<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.
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>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>
Notepad isn't a &quot;powerful scripting program&quot; it's a simple text-editor.<br /> <br /> L<br />
IMHO A simple Text editor is a powerful programming tool. It used to be all there was. If you know what you're doing, a text editor might be all you need. <br> <br>try this from a windows command line. do it from a directory where you have write permissions. <br> <br> <br>Type <br>c:\scripts&gt; echo x=msgbox(&quot;Your text here.&quot; ,0,&quot;Title here&quot;)&gt;mbscript.vbs <br> <br> <br>Type <br>c:\scripts&gt; cscript mbscript.vbs <br> <br> <br>You've just written a vbscript without any text editor at all. <br>to add more lines use &gt;&gt; instead of &gt; before the file name. <br> <br> <br>Notepad, edit, vi, emacs whatever you use, a text editor IS a powerful tool. <br>
after it creates the mbscript.vbs file how do you write into the newly created vbs file with code? <br> <br>lets say...within that file i want to create a code that tell a program to run
Tell me what you're trying to do. So I can answer the question most thoughtfully. <br> <br>I think I understand, but I want to be sure before I write up a bunch of stuff you don't need. <br> <br>Thanks.
using your code <br>************* <br>c:\scripts&gt; echo x=msgbox(&quot;Your text here.&quot; ,0,&quot;Title here&quot;)&gt;mbscript.vbs <br>*********** <br> <br>it creates an empty vbs script called &quot;mbscript&quot;...................now after it has done so, how do i write a code (from the same notepad i used to create the mbscript.vbs) in addition that fills the empty mbscript.vbs with a code to lets say...run another program?
Make sure you're at the command prompt. <br> <br>You can get there like this: <br> <br>go to start <br>then run <br>then type CMD <br>and hit enter <br> <br>that will open the command line. It's a black screen with a blinking cursor and something like <br> <br>C:\&gt;_ the underscore represents the cursor. you don't type &quot;c:\&gt;&quot; <br> <br>you type only the following that is between the outer most quotes. <br> <br>&quot;echo x=msgbox (&quot;Your Text Here&quot; ,0, &quot;Your Title Here&quot;)&gt;msgbox.vbs&quot; <br> <br>That will work. I just now did it. <br> <br>when you type script msgbox.vbs you'll get a message box with an OK button. <br> <br>i've only used the technique I've described in an emergency where I was in a unique situation. sometimes I use it to create batch file. it's because I use linux a lot and I'm used to the command line. <br> <br>It's not really practical to write an entire script like that. <br>I suggest you use the Notepad.exe as described in this fine instructable. <br> <br>or if you can't get to notepad you can type &quot;edit&quot; at the command prompt and you'll get a text based editor. Well, you will on XP anyway. I don't know about windows 7 for sure. <br> <br>If you want to now how to program you should google &quot;vbscript fundamentals&quot; you should find the MSDN site for VBScript. Pretty much all you need to know is there. <br> <br>If you want examples of vbscripts you should google. vbscript examples. you'll get tons of source code. but start with something basic as in simple or easy. at first and work your way up. <br> <br>I hope this helps. <br> <br>Let me know if you need anything else. <br> <br>Christophor <br> <br> <br> <br>
sorry you have to type <br> <br>c script with no spaces. my spell checker keeps fix it for some reason. <br> <br>you could click on it to run it if you use the windows interface. <br> <br>probably you could just type msgbox.vbs and it will run.(after you've created it.) <br> <br>good luck.
No.<br> The power is in a person's mind, Notepad is a simple text-editor.<br> <br> L
I agree with you. Notepad is a simple text editor. Nothing more and nothing less.<br><br>I think we can both agree, if you can't code with a simple text editor then you can't really code anyway.<br><br>But, let's say simple text editors represent the minimum standard in scripting tools.<br><br>What exactly would you say IS an example of &quot;a powerful scripting program?&quot; What makes it more powerful than (insert name of text editor here)?<br><br>I'm not being hostile. I really want to know. I use notepad and notepad ++ on a daily basis. They are both simple text editors at heart. <br><br>Notepad is great for filtering formatting codes from cut text. Cut from excel. Paste into notepad. Presto! Nice clean text. Cut it from notepad and paste it into whatever like.<br><br>I look forward to your reply.<br><br>Thanks, Lemonie.<br><br>- Chris<br><br><br>
&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?

About This Instructable




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