The Computer Oracle

What scripting languages are useful in Windows?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Intrigue Looping

--

Chapters
00:00 What Scripting Languages Are Useful In Windows?
00:12 Answer 1 Score 10
00:30 Accepted Answer Score 38
02:12 Answer 3 Score 16
03:12 Answer 4 Score 4
03:32 Thank you

--

Full question
https://superuser.com/questions/288233/w...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows #script

#avk47



ACCEPTED ANSWER

Score 38


Windows has 3 built-in solutions to consider:

  1. PowerShell
  2. Windows Scripting Host
    a. VBScript
    b. JScript
  3. Batch Files

PowerShell (v2.0)

As of Windows 7 and Server 2008, it's reasonable to consider PowerShell as it ships with Windows and is also fundamental for administering server software such as Lync and Exchange. There is a growing list of features available; see Script Center for details.

Windows Scripting Host

Windows Script Host (WSH) is technically a scripting host for ActiveX Scripting Engines. VBScript and JScript (Microsoft's implementation of JavaScript) are the two engines installed by default. Many others are available from the open source community, including Perl, PHP, and Ruby.

VBScript

Using similar syntax to VB6 and VB.NET, VBScripts lack easy access to .NET classes (Powershell is written on .NET so it has access to all the .NET functions). VBScript mostly takes advantage of the WMI service and the objects it exposes.

Example: creating a restore point.

Set wmi, whatName, errResults
wmi = GetObject("winmgmts:\\.\root\default:Systemrestore")
whatName = InputBox("Enter a name for the Restore Point", WScript.ScriptName)
errResults = wmi.CreateRestorePoint (whatName, 12, 100)
If errResults <> 0 then
    Wscript.Echo "Error " & errResults & " : Unable to create Restore Point"
End If

JScript

The same script can be written using ECMAScript:

var wmi = WScript.GetObject("winmgmts:\\.\root\default:Systemrestore");
var whatName = WSHInputBox("Enter a name for the Restore Point", Script.ScriptName);
var errResults = wmi.CreateRestorePoint(whatName, 12, 100);
if(errResults != 0) {
    WScript.Echo("Error " + err + " : Unable to create Restore Point");
}

Command Batch Files

There is of course the good ol' Batch File. They need no intro.




ANSWER 2

Score 16


I still write DOS batch files, even in Windows 7. For most tasks, this still works quite well, and it's very simple to work with (also, many of the DOS commands such as "FOR" have been improved over time and provide more options and functionality that weren't available more than a decade ago).

For me, a DOS batch file is still the main scripting language for Windows (it certainly is traditional), but everyone has needs and preferences that differ. There are many things that DOS batch files can't do (scripting languages can pose limitations too), and for the rare occasions where I've encountered this I then look at what my other options are (often it's Perl, or sometimes it could be to write a small program or an entire application).

Understanding what you need to accomplish is a very important step in deciding which tools to use. Familiarity with the tools is another important aspect that can limit your options. If you're trying to decide which scripting [or programming] language to learn, then hopefully this will be helpful to you.




ANSWER 3

Score 10


That depends on who you ask. Some will never leave batch, some love vbscript some love powershell, others like AutoIt. Then there are the platform independent ones like Python and Perl that some will swear by for everything.




ANSWER 4

Score 4


I would say AutoIt, it provides very fast and easy developedment on windows and is very tight coupled with it. This means that tasks that usually take rather much code in other languages can be done in literally one line in autoit. Features such as direct compilation to exe's is also very useful.