Intro to Scripting Tech on Windows (Compared to Unix)
In 2009, i Switching from Mac/Unix to Windows, after 10 years as a programer and sys admin on the unix environment. This page is my learning notes about scripting tech on Windows.
Here's a table listing technologies on unix and Windows that have similar purposes.
|Shell||Bash||cmd.exe, PowerShell||cmd.exe aka batch script is old. PowerShell is new with Windows 7.|
|Advanced sys admin||Perl, Python||VBScript, PowerShell||◇|
What is 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.
- Visual Basic .NET is a new version of Visual Basic based on the .NET platform.
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).
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 is the difference between VBScript, Windows Script Host, and PowerShell?
- MS-DOS is a operating system of the 1980s and early 1990s. It is basically command-driven in a text-only display of the time (Monochrome monitor).
- command.com comes with the graphical OS Windows 95. “command.com” is command-line interface compatible to MS-DOS.
- “cmd.exe” comes with Windows NT line (late 1990s), and is used in Windows XP, Vista, 7.
- PowerShell is the next generation of scripting lang. It comes with Windows 7.
Basically, MS-DOS, command.com, cmd.exe are all meant to be the same thing, but with different implementation. This is similar to unix command line evolution sh → tcsh → bash.
Windows Script Host (WSH) is created in late 1990s, because cmd.exe is not powerful for scripting. WSH is 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 file name 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.
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.
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 (For example, 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).
Meaning of “Shell” in unix and Windows
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.
“script” and “batch file”
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.
Terminal vs Console
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.
See also: Windows Console Key Shortcuts.
If you have a question, put $5 at patreon and message me.