domingo, 31 de enero de 2010

VBScript

VBScriptOneRiotYahooAmazonTwitterdel.icio.us

De Wikipedia, la enciclopedia libre


VBScript (abreviatura de Visual Basic Script Edition) es un lenguaje interpretado por el Windows Scripting Host de Microsoft. Su sintaxis refleja su origen como variación del lenguaje de programación Visual Basic. Ha logrado un apoyo significativo por parte de los administradores de Windows como herramienta de automatización, ya que, conjunta y paralelamente a las mejoras introducidas en los sistemas operativos windows donde opera fundamentalmente, permite más margen de actuación y flexibilidad que el lenguaje batch (o de proceso por lotes) desarrollado a finales de los años 1970 para el MS-DOS.

El crecimiento del uso de las tecnologías de Internet ha supuesto un significativo avance para este lenguaje, dado que es parte fundamental de la ejecución de aplicaciones de servidor programadas en ASP (Active Server Pages), las cuales están en auge en el período 1997-2003, declinando actualmente en favor de tecnologías de código gestionado y máquinas virtuales, más seguras en la ejecución de procesos, y por tanto, más adaptadas para ejecuciones en entornos públicamente accesibles y distribuidos. Microsoft ha intentado competir mediante esta tecnología también en entornos de cliente, donde el lenguaje más utilizado es Javascript o su versión estandarizada ECMAScript, sin éxito. Actualmente microsoft no ha puesto a disposición pública nuevas versiones del lenguaje, en favor de la tecnología .NET en la que se incluye el lenguaje hermano Visual Basic, dentro del entorno de ejecución de la plataforma .NET (CLR, o Common Language Runtime). Sin embargo sigue siendo muy útil en gestión de estaciones de trabajo y servidores en windows.

Contenido

[ocultar]

Interpretación [editar]

VBScript es interpretado por el motor de scripting vbscript.dll, que puede ser invocado por el motor ASP asp.dll en un entorno web, por wscript.exe en un entorno Windows de interfaz gráfica, por cscript.exe es un entorno de línea de comandos y por iexplore.exe cuando se trata de scripts a nivel de cliente (similar al javascript). Cuando el código fuente VBScript se guarda en ficheros independientes, éstos tienen típicamente la extensión .vbs.

Cuando se emplea en Internet Explorer, VBScript funciona de forma muy similar a JavaScript, procesando código contenido en el documento HTML. VBScript también puede usarse para crear aplicaciones HTML independientes (extensión .hta), que necesitan Internet Explorer 5.0 o superior para poder ser ejecutados. Los desarrolladores de aplicaciones en web suelen preferir JavaScript debido a su mayor compatibilidad con otros navegadores de Internet, ya que VBScript sólo está disponible para el navegador de Microsoft Internet Explorer, y no en otros como Firefox u Opera.

Seguridad [editar]

VBScript es el lenguaje usado para escribir algunos famosos gusanos de red, como I Love You. Esto se debe a varias razones. Primero, el icono parecido a un pergamino azul que representa a los ficheros .vbs puede llevar a pensar a los usuarios inexpertos que se trata de un fichero de texto. Segundo, es fácil escribir un gusano informático en VBScript que se propague por correo electrónico (se necesitan pocas líneas de código). Microsoft ha solucionado los agujeros de seguridad explotados por dichos programas maliciosos. Este solucionado no significa erradicado, solo ha complicado el proceso; pues si por ejemplo el I Love You se propagaba a través del Outlook, ahora si se utiliza el mismo método sale un mensaje de advertencia, por lo que se suele emplear métodos como el envío mediante un servidor smtp (bastante más complejo de programar que por el otro método).

Sintaxis [editar]

VBScript es compatible y se puede usar tal cual en VB6, a excepción de las funciones siguientes, que tiene su similar en VB6 y difieren (ninguna más):

  • Execute (no existe en VB6, y no tiene similar)
  • Do...Loop Until (en este caso se cambia el orden poniendo Do Until...Loop)
  • VBScript.Sleep (esto se sustituye por una API llamada Sleep).
  • VBScript.Quit (se sustituye por UnLoad Me)

Por lo demás, ambos son exactamente idénticos, es más VB6 amplia la base que se ha aprendido en VBScript. Se recomienda fervientemente pues a los programadores de VB6 (nunca es tarde) que aprendan este simple y sencillo lenguaje.

Enlaces externos [editar]



VBScriptOneRiotYahooAmazonTwitterdel.icio.us

From Wikipedia, the free encyclopedia

Jump to: navigation, search
VBScript
Usual file extensions .vbs, .vbe, .wsf, .wsc (.htm, .html, .asp)
Appeared in 1996
Developer Microsoft
Stable release 5.8
Major implementations Windows Script Host, Active Server Pages
Influenced by Visual Basic
Influenced Windows PowerShell
OS Windows

VBScript (short for Visual Basic Scripting Edition) is an Active Scripting language, developed by Microsoft, which uses the Component Object Model to access elements of the environment within which it is running (e.g. FileSystemObject or FSO used to create, read, update and delete files). The language's syntax reflects its origins as a limited variation of Microsoft's Visual Basic programming language.

VBScript has been installed by default in every desktop release of Microsoft Windows since Windows 98[1]; as part of Windows Server since Windows NT 4.0 Option Pack[2]; and optionally with Windows CE (depending on the device it is installed on).

A VBScript script must be executed within a host environment, of which there are several provided with Microsoft Windows, including: Windows Script Host (WSH), Internet Explorer (IE), Internet Information Services (IIS). Additionally, The VBScript hosting environment is embeddable in other programs, through technologies such as the Microsoft Script control (msscript.ocx).

Contents

[hide]

[edit] History

VBScript began as part of the Microsoft Windows Script Technologies, which were launched in 1996, initially targeted at web developers. During a period of just over two years, the VBScript and JScript languages advanced from version 1.0 to 2.0, and over that time it gained support from Windows system administrators seeking an automation tool more powerful than the batch language first developed in the late 1970s.

In version 5.0, the functionality of VBScript was increased with new features such as: regular expressions; classes; the With statement[3]; the Eval, Execute, and ExecuteGlobal functions to evaluate and execute script commands built during the execution of another script; a function-pointer system via GetRef[4], and Distributed COM (DCOM) support.

In version 5.5, SubMatches[5] were added to the regular expression class in VBScript, to finally allow VBScript script authors to capture the text within the expression's groups. That capability before was only possible through JScript.

With the advent of the .NET framework, the scripting team took the decision to implement future support for VBScript within ASP.NET for web development[6], and therefore no new versions of the VBScript engine would be developed and it moved over to being supported by Microsoft's Sustaining Engineering Team, who are responsible for bug fixes and security enhancements. For Windows system administrators, Microsoft suggests that they migrate to Windows PowerShell. However the scripting engine will continue to be shipped with future releases of Microsoft Windows and IIS.

[edit] Uses

When employed in Microsoft Internet Explorer, VBScript is similar in function to JavaScript, as a language to write executable functions that are embedded in or included from HTML pages and interact with the Document Object Model (DOM) of the page, to perform tasks not possible in HTML alone. Other web browsers such as Firefox, and Opera do not have built-in support for VBScript. This means that where client-side script is required on a web site, developers almost always use JavaScript for cross-browser compatibility.

Besides client-side web development, VBScript is used for server-side processing of web pages, most notably with Microsoft Active Server Pages (ASP). The ASP engine and type library, asp.dll, invokes vbscript.dll to run VBScript scripts. VBScript that is embedded in an ASP page is contained within <% and %> context switches. The following example of an ASP page with VBScript displays the current time in 24-hour format (Note that an '=' sign occurring after a context switch (<%) is short-hand for a call to Write() method of the Response object).

 <% Option Explicit

%>


VBScript Example


<%
' Grab current time from Now() function.
Dim timeValue
timeValue = Now() %>
The time, in 24-hour format, is <%=Hour(timeValue)%>:<%=Minute(timeValue)%>:<%=Second(timeValue)%>.



VBScript can also be used to create applications that run directly on a person's computer running Microsoft Windows. The simplest example of this is a script that makes use of the Windows Script Host (WSH) environment. Such a script is usually in a stand-alone file with the file extension .vbs. The script can be invoked in two ways. Wscript.exe is used to display output and receive input in through a GUI, such as dialog and input boxes. Cscript.exe is used in a command line environment.

VBScript .vbs files can be included in two other types of scripting files: .wsf files, which are styled after XML; and .hta files, which are styled after HTML. .wsf files can be executed using wscript.exe or cscript.exe, just like .vbs files, and .wsf files can include multiple .vbs files. As a result .wsf files provide a means for code reuse: one can write a library of classes or functions in one or more .vbs files, and include those files in one or more .wsf files to use and reuse that functionality in a modular way.

Another employment of VBScript is the HTML Application, or HTA (file extension .hta). In an HTA, HTML is used for the user interface, and a scripting language such as VBScript is used for the program logic. HTAs run inside of mshta.exe, which is a 'Trusted Application Environment' provided by Internet Explorer. The 'Trusted Application Environment', implies that HTAs do not suffer the restrictions applied to applications running in the web or intranet zone, such as accessing local files or network paths. Although HTAs run in this 'trusted' environment, querying Active Directory can be subject to Internet Explorer Zone logic and associated error messages.

VBScript (and JScript) can be used in a .wsc file to create a Windows Script Component - an ActiveX-enabled script class that can be invoked by other COM-enabled applications[7].

Lastly, VBScript has been adopted as the internal scripting language for some embedded applications, such as industrial operator interfaces and human machine interfaces.[citation needed]

[edit] Functionality

As-is, VBScript provides functions and sub-routines, basic date/time, string manipulation, math, user interaction, ease of access, error handling, and regular expressions. Additional functionality can be added through the use of ActiveX technologies. File system management, file modification, and streaming text operations can be achieved with the Scripting Runtime Library scrrun.dll. Binary file and memory I/O is provided by the "ADODB.Stream" class, which can also be used as a string builder (since a high amount of VBScript string concatenation is costly due to constant memory re-allocation), and can be used to convert an array of bytes to a string and vice versa. Database access is made possible through ActiveX Data Objects (ADO), and the IIS Metabase can be manipulated using the GetObject() function with sufficient permissions (useful for creating and destroying sites and virtual directories). Additionally, XML files and schemas can be manipulated with the Microsoft XML Library Application Programming Interfaces (msxml6.dll, msxml3.dll), which also can be used to retrieve content from the World Wide Web via the XMLHTTP and ServerXMLHTTP objects (class strings "MSXML2.XMLHTTP.6.0" and "MSXML2.ServerXMLHTTP.6.0", respectively).

Security concerns have led to many ActiveX controls being blacklisted in the Internet Explorer process by Microsoft, who deploy the "killbit" via monthly Windows security updates to disable vulnerable Microsoft and third party code.[8][9]

[edit] Hello World

This is an example of Hello World in VB script

MsgBox("Hello World")

For this to run it must be saved as a .vbs file.

[edit] See also

[edit] References

[edit] External links

Categories: BASIC programming language family | Scripting languages | Microsoft Windows | Internet Explorer
En otros idiomas





No hay comentarios:

Publicar un comentario

Correo Vaishnava