Execute files using WScript [including executable exe file]vbs scripts _vbs

Source: Internet
Author: User
Tags html page
Yesterday downloaded and installed the Updater Application block, the need to execute a deploy.vbs file, I talents, this small problem unexpectedly also cost me a lot of scheming.
Now share the conclusion.

First of all, my VBS file association has been captured by "hero". I double-click Deploy.vbs will open hero, more depressed. But I used the open way, tried the browser, cmd, no avail.

Today, when I think about this, I have an idea to go up to Microsoft News Group to ask a question. And then went to Csdn's Full-text search. Sure enough, my key word is only VBS, implementation, I found a lot of stuff I want. Learn to use Wscript.exe to execute this file.

Wscript.exe deploy.vbs in cmd, but the return error is There are no script engine for file extension '. vbs '. This time I think of Google. Sure enough, there was a lot of useful information, and the first one I found a solution. The reason is that my VBS association has been lost and must display the specified.

CMD-typed wscript.exe//e:vbscript deploy.vbs. It was a success!!!



Summary: Use Wscript.exe to execute script files like VBS. If the file association is missing. You can use//e:vbscript.



Attached is a helpful article I found.


One, what is WSH?

wsh is an abbreviated form of Windows Scripting Host (Windows Scripting Host). The WSH concept first appeared on the Windows 98 operating system and was a script-run environment based on a 32-bit Windows platform and language-independent. For example, you write a script file, such as a file with a. vbs or. js suffix, and then double-click and execute it under Windows, and the system automatically invokes an appropriate program to interpret and execute it, and this program, the Windows scripting Host, Program execution file name is Wscript.exe (if at DOS command prompt, Cscript.exe).

£

Do you want to know if there are any WSH on your machine? Check your machine for a "Wscipt.exe" or "Cscript.exe" of these two files. If you find it, congratulations! You have installed the WSH. Otherwise, manually install it yourself:

In Windows 98 environment, WSH is installed as a component of the operating system automatically, and if you accidentally lose this component, you can open the Control Panel--> Add/Remove Programs--〉windows Setup--〉 attachments in turn, and then "Windows Scripting Host "√", and then determined to complete the installation of WSH components.

£

The relationship between script language and WSH

As you know, scripting languages, including JavaScript and VBScript languages, are often embedded in Web pages (including HTML page client side and ASP Page Server side). For scripts implanted with HTML pages, the parsing engine required is loaded by a Web browser such as IE, and the required parsing engine is provided by IIS (Internet information Services) for scripts that embed ASP pages. For scripts that appear outside of HTML and ASP pages (which often exist as standalone files), they need to be processed by WSH. What needs to be explained is: WSH to work properly, also installs IE 3.0 or later version of IE, because WSH at work will invoke the VBScript and JavaScript parsing engine in IE. [Not ended] [Iduba_page] The vast majority of these scripting languages that are embedded in Web pages are not related to network security. But there are also a handful of bad people who have ulterior motives, to put some code that is seriously endangering network security (which we often call "malicious code"), usually by modifying the registration to express "malicious" Purpose! , mixed in normal scripts, often keep us out of the way. However, if we understand a little bit about scripting language, these "tricks" are very easy to see. Let's start with a few simple examples ...

£

Three, WSH application examples

WSH can handle script programs, how to read and write WSH script source files? As long as you have a little basic (will VB programming better, hehe) Language Foundation, learn to read WSH script language program is not a difficult thing. Go to the C:WINDOWSSAMPLESWSH directory below will look at it! There are a few classic examples of scripting in it, and there are two versions of VBScript and JavaScript, each of which is not difficult to learn about basic WSH applications, as long as we open them in Notepad and study them carefully.

£

You simply enter the code in each of the following instances in Notepad and save it as the corresponding "*.vbs" file, and you can see the corresponding effect by double-clicking the file.







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

A:This is similar to the *.js association problem. Some machines seem to, for Some reason, lose their and *.vbs association. It's not so the the files open with Dreamweaver or whatever--it's that's machine just doesn ' t know to run them. If you are have a scheduled task, "could not run" would appear in the Status column.

So, your ' re a smart person and read through the FAQ. You find the *.js extension problem, and your 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 be no script engine for Fil e extension '. vbs '. So, for some reason, WScript doesn ' t even know-do with what files.

The solution to this problem are to run the script as:

WScript//e:vbscript C:\path\to\script.vbs

The "//e:vbscript" tells WScript to use the VBScript engine to parse the script. It would then run correctly.

A few alternative solutions, perhaps easier are:

Rename it. VBE (VBScript encoded Script File). Not sure if-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 and along with the//e:vbscript. This is probably the "correct" solution ...
This problems usually occurs only on Windows XP machines and But the cause is not known. A Microsoft KB Article on this issue can is found here. 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.