This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/jinghaianlange/archive/2007/07/16/1693653.aspx
◎ Vbs Script Programming Tutorial II-how to start the first vbs script?
Like most computer tutorials !"ProgramStart our exercises. What? What does it mean? That is to say, the beginning of most computer programming tutorials is to write a small program. The result of executing this program is to display a line of text on the computer screen or DOS window: Hello world! Okay. Let's get started.
Open your notepad program and fill in the following information in the editing window:
Msgbox "Hello world! "
Click the "file" menu, click "save", set "Save in" to "desktop", and fill in KK in the "file name" column. vbs, click "save. Then, minimize the "Notepad" window, search for your saved KK. vbs on the desktop, and double-click it. The pop-up dialog box does not exist. Click OK. The dialog box disappears. It is ugly, but it is indeed the first script program you have written.
Note: In the above operations, the storage location is placed on the desktop, just for convenience, you can save it to other places, as long as you know where you saved it, what? It's nonsense. You can save it. No, I see more people I can't find my saved files. You can enter the file name at will, not necessarily write KK, as long as it complies with the Windows File naming rules, but the extension must be vbs. What? I don't know what the extension is? It is the part after "." In the file name. Simply put, the vbs script file must be named XXX. vbs, where XXX is random.
NOTE 2: What does this line mean in the notepad editing window?
Msgbox is a vbs built-in function. Each function can complete certain functions. You only need to enter the corresponding content in the corresponding part of the function according to the syntax requirements, this part of content is called a parameter. Of course, the result of function execution is called a return value. A function can have either a return value or a parameter. You don't need to know how a function works. You just need to know what this function can do.
Msgbox Syntax: msgbox "dialog box content", "dialog box title"
Open the file in notepad and enter the following in the editing window:
Msgbox "Hello world! "," System prompt"
Run the command to check the effect and position.
NOTE 3: If the execution fails, check your punctuation marks. All punctuation marks must be entered in English.
Of course, this script is too simple to even have the simplest interaction, so you can modify it like this:
Dim name
Name = inputbox ("enter your name:", "name ")
Msgbox name, "Your name is"
Save and run the command. Is the pop-up dialog box displayed? Enter your name and click OK. Have you seen the result?
Description: The first clause defines variables, and dim defines variables.
The format is dim variable 1, variable 2 ......,
Vbs only has one variable type, so you do not need to declare the variable type. The system automatically identifies the variable type.
NOTE 2: inputbox is a vbs built-in function that can accept input content. Its Syntax format is:
Inputbox ("dialog box content", "dialog box title ")
The second sentence means accepting user input and passing the input result to the variable name.
Now, the basic input and output functions of this script are available, and some simple functions can be completed. You can compile a simple script, copy the program> start, and restart the computer to check the result.
If you use the above script to start the system, there will be a major problem on Vista, including the failure to start the control panel, the failure to open the computer attribute, and the failure to start Windows Update. Whether or not this problem occurs in Windows 7 remains to be studied.