Use wscript to execute the file [including executable exe files] vbs script

Source: Internet
Author: User

After downloading and installing the Updater Application Block yesterday, you need to execute a Deploy. vbs file, which is easy to learn. This small problem actually took a lot of time.
Share the conclusion.

First, my vbs File Association has been captured by hero. Double-click Deploy. vbs to open the hero. However, I used the open method and tried the browser and cmd.

Today, after thinking about this question, I have an idea to go to Microsoft's News Group and ask. Then I went to the full-text search of CSDN. It is really disappointing. My keyword is only vbs. After execution, I found a lot of things I want. Wscript.exe is used to execute this file.

Wscript.exe Deploy. vbs is typed in the response, but the error "There is no script engine for file extension'. vbs" is returned '. At this time, I thought of google. I found a lot of useful information, and I found a solution in the first one. The reason is that my vbs Association has been lost and must be specified.

Run wscript.exe // e: vbscript Deploy. vbs in cmd. Sure enough !!!

Conclusion: wscript.exe is used to execute script files such as vbs. If the file association is lost. You can use // e: vbscript.

Attached is a helpful article I found.

1. What is WSH?

WSH is the scaling form of Windows Scripting Host (Windows Script Host. WSH was first introduced in the Windows 98 operating system and is a language-independent script running environment based on a 32-bit Windows platform. For example, you have compiled a script file, such as the suffix. vbs or. js file, and then double-click and execute it in Windows. Then, the system will automatically call an appropriate program to explain and execute it, and this program, it is Windows Scripting Host, and the program execution file name is Wscript.exe (Cscript.exe if it is at the DOS command prompt ).

Do you want to know if WSH is available on your machine? If your machine does not contain the wscipt.exe000000000000cscript.exe files, you can. If you find it, congratulations! You have installed WSH. Otherwise, install it manually:

In Windows 98, WSH is automatically installed as a component of the operating system. If this component is accidentally lost, you can open "control panel --> Add/delete procedure --> Windows Installer --> attachment" in sequence, and then forward "√" before "Windows Scripting Host ", then confirm the installation of the WSH component.

Ii. Relationship between script language and WSH

As you know, scripting languages (including JavaScript and VBscript) are often embedded into webpages (including HTML page clients and ASP page servers ). For scripts implanted in HTML pages, the parsing engine is loaded by Web browsers such as IE. For scripts implanted in ASP pages, the required parsing engine is provided by IIS (Internet Information Services. For scripts that appear outside the HTML and ASP pages (they often exist in the form of independent files), they need to be processed through WSH. To work properly, install IE 3.0 or later, because WSH will call VBScript and JavaScript parsing engines in IE. [Not ended] [iduba_page] Most of these scripting languages implanted on webpages are irrelevant to network security. However, there are also a few good people with ulterior motives who put some code that seriously threatens network security (we often call it "malicious code ", they usually need to modify the Registry to "malicious !), Mixing in normal scripts often makes it difficult for us to defend against attacks. However, if we know a little bit about the scripting language, these "tricks" are very easy to understand. Let's start with some simple examples ......

3. WSH application example

WSH can process the script program. How can I read and write the WSH script source file? As long as you have a little bit of Basic (VB programming is better, huh, huh) language basics, it is not difficult to learn to understand programs in the WSH script language. Go to the C: WINDOWSSAMPLESWSH directory! There are several typical script examples, and VBScript and JavaScript versions are provided respectively. It is not difficult to learn some basic WSH applications as long as we open them in notepad and study them carefully.

In notepad, you only need to enter the code in each of the following instances in sequence, save it as the corresponding "*. vbs" file, and double-click the file to see the corresponding effect.

Q: How do I open script files? Trying the above solution makes Windows XP throw an error?

A: This is similar to *. js association problem. some machines seem to, for some reason, lose their *. vbs association. it's not that the files open with dreamweaver or whatever -- it's that the machine just doesn't know how to run them. if you have a scheduled task, "cocould not run" will appear in the status column.

So, you're a smart person and read through the FAQ. you find *. js extension problem, and you try that fix: you run it as "wscript c: \ path \ to \ script. vbs ". but that, in turn, produces a pop-up error, this time a "Windows Scripting Host" error: "There is no script engine for file extension '. vbs '. "So, for some reason, wscript doesn't even know what to do *. vbs files.

The solution to this problem is to run the script:

Wscript // e: vbscript c: \ path \ to \ script. vbs

The "// e: vbscript" tells wscript to use the vbscript engine to parse the script. It will then run correctly.

A few alternative solutions, perhaps easier are:

Rename it. vbe (VBScript Encoded Script File). Not sure if this is a bad idea, but it seemed to work for some scripts.
Make a new association for VBS. open up my computer, select Tools menu-> Folder Options, and go to the File Types tab. there probably isn't a VBS association listed if you have this problem. select New, type in VBS, and hit Advanced>. then, from the pull-down menu, select "VBScript Script File ". making this selection automatically takes care of the association, along with the // e: vbscript problem. this is probably the "correct" solution...
This problems usually occurs only on Windows XP machines, but the cause is not known. A Microsoft KB article on this issue can be found here. Thanks goes to Bob_2k for writing this FAQ entry.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.