Xah Lee, 2009-06-28
This page gives a introduction of differences in scripting tech in unix and Windows, in particular, from point of view of a professional sys admin or programer moving from unix to Windows.
Here's a table listing technologies on unix and Windows that have similar purposes.
| ◇ | unix | Windows | Comments |
|---|---|---|---|
| Basic | Bash, | cmd.exe, PowerShell | ◇ |
| Shell Utils | List of Unix utilities | List of DOS commands | ◇ |
| Application Scripting | AppleScript (OSX) | VBA (MS Office) | VBA = Visual Basic for Applications. On linux, lang varies depending on the app; typical are Python, Perl, Tcl, Scheme lisp, Javascript variant. |
| Advanced sys admin | Perl, Python | VBScript, PowerShell | ◇ |
| Web Server Side | PHP, Perl, Python | Active Server Pages | Active Server Pages (ASP) uses JScript (JavaScript) or VBScript (Visual Basic) as langs. |
| Web Client Side | Javascript | Javascript, VBScript | ◇ |
What's the difference between Visual Basic, VBA, VBScript, Visual Basic .NET?
Visual Basic is a general purpose computer language. VBA (Visual Basic for Applications), is a language embedded in Microsof Office applications for scripting these apps. VBScript is a version for Windows sys admin and web app client-side scripting. They are the same language just differ a bit because of the context. However, they don't run on the same engine (but they do share the use of many Microsoft's component tech such as COM and DLL).
Visual Basic .NET is a new version of Visual Basic based on the .NET platform.
The latest version of the classic Visual Basic is VB 6. VB 6 is no longer supported. It is replaced by the .NET version, and it has version naming starting at VB 7 and currently VB 10. However, VB 6 will still be included in Windows 7. VB 6 will probably be around for many years in practice.
What's the diff between VBScript, Windows Script Host, and PowerShell?
In the beginning, there's MS-DOS, which is a operating system of the 1980s and early 1990s that operates by commands in a text terminal. With Windows 95, it came with a compatible command-line interface app called command.com, and in Windows NT line (late 1990s), the same is called cmd.exe. This is the evolution of Windows's command line interface, similar to unix's sh → tcsh → bash.
However, cmd.exe is not sufficiently powerful as time moved on. Similarly, unix's bash, awk, sed, find/xargs grep etc isn't powerful enough, therefore came Perl (and later tcl, python, etc.). Same in the Windows world, cmd.exe isn't powerful enough, in fact less than what unix shells can do. Instead of creating just one new scripting lang as in the unix world, Microsoft created the Windows Script Host (WSH) technology, bundled with Windows 98. Quote:
The Microsoft Windows Script Host is an automation technology for Microsoft Windows operating systems that provides scripting capabilities comparable to batch files, but with a greater range of supported features.
It is language-independent in the sense that it can make use of different scripting language engines. By default it interprets and runs plain-text JScript (.JS and .JSE files) and VBScript (.VBS and .VBE files). Users can install different scripting engines to enable them to script in other languages, for instance PerlScript. The language independent filename extension WSF can also be used. The advantage of the Windows Script File (.WSF) is that it allows the user to use a combination of scripting languages within a single file.
WSH is just a hosting engine, it needs scripting engines such as VBScript (Visual Basic) and JScript (JavaScript).
In 2006, Microsoft released PowerShell, which is a new shell design based on .NET technology. PowerShell is more versatile and powerful than WSH+VBScript because it can be used interactively as a shell like cmd.exe, and it is also a full scripting lang that are fully integrated with the .NET platform, and can use all .NET libraries. Going forward, PowerShell is a replacement for the whole cmd.exe and WSH bag. PowerShell comes pre-instaled with Windows 7 (to be released in 2009-10).
What is Active Scripting?
Active Scripting (aka ActiveX Scripting) is more or less a marketing term that MS uses collectively to describe MS's scripting tech, including JScript, VBScript, ASP (Active Server Pages), WSH (Windows Script Host). Active Scripting is deprecated by MS's .NET Framework.
In unix, you script using bash, shell tools (e.g. find, grep, sed, awk, make), or perl and python. In Windows, scripting are done with VBScript and now PowerShell.
Visual Basic is one of the most important way to script Windows for sys admin as well as writing standalone Windows applications. Its role is similar to Python or Perl, but unlike unix's scripting techs which are largely all independent, Visual Basic is tightly integrated and dependent on various Microsoft's component technology to work.
When scripting Windows for sys admin tasks, often you'll also make use of Windows Management Instrumentation (WMI) and Active Directory Service Interfaces (ADSI).
In unix world, a “shell” refers to the command line interface to the OS. In Windows, Windows Shell refers to the whole GUI, in particular the file manager Windows Explorer, and taskbar and Start Menu. The Windows command line interface is called Command Prompt, and the program name is “cmd.exe”. It is to be replaced by PowerShell in Windows 7.
In unix world, a “script” refers to text file of shell commands or constructs. In Windows, a file of cmd.exe commands is often called a Batch file instead. However, PowerShell or VBScript files are still called scripts.
In unixes, to run a shell, you start a Terminal emulator, which is configured to start bash or tcsh.
(in linuxes, the terminal emulator app is often xterm , and on OS X the program is called Apple Terminal.)
Terminal Emulator or Console are terminologies from the 1970s and 1980's, and their meaning is a bit fuzzy now. Physical Terminal or Console has been pretty much obsolete since late 1990s. The terms “terminal emulator” or “console” today mostly just refer to a command line app.
In windows, its terminal is called Win32 console, which hosts the cmd.exe and PowerShell.
In unixes, you start the terminal app, which then is configured to automatically start a shell such as bash. In windows, you don't do that. You start the cmd.exe or powersell process directly. These programs are written with the Windows Console as its interface.
For scripting tasks on Windows sys admin, you need to know basics of cmd.exe. For advanced admin, you need to master VBScript, which is the bread & butter tool right now. Visual Basic is important because it is among the top 5 most used language. (the top langs include: Java, C, C++, PHP, Visual Basic, C#, Python, Perl, JavaScript) Going forward, you should learn PowerShell, which is included with Windows 7 and posed to replace cmd.exe and VBScript for sys admin tasks.
See also: Windows Console Shortcuts.
Related essays: