6

Possible Duplicates:
Best “official” scripting language for Windows programmers
Universal scripting language for Windows
What tools and languages are available for windows shell scripting?

I work in Windows and often find the need to code some script that manipulates files or basic string manipulation. Currently, I'm doing this using PHP but having a LAMP stack for this seems overkill. I've tried things like autoHotkey but the syntax and functionality is horrific.

So I'm looking for a scripting with: a) a sane syntax b) lots and lots of built-in libraries, functions, etc c) minimal setup. Preferably, I would like to code and run the script from my app launcher of choice, Executor

Community
  • 1
  • 1
WhyKiki
  • 101
  • 9
  • 5
    http://stackoverflow.com/questions/1104886/universal-scripting-language-for-windows http://stackoverflow.com/questions/326775/best-official-scripting-language-for-windows-programmers http://stackoverflow.com/questions/32087/what-tools-and-languages-are-available-for-windows-shell-scripting http://stackoverflow.com/questions/546275/windows-scripting-vbscript-dos-js-python – Jørn Schou-Rode Apr 18 '10 at 18:07

8 Answers8

14

Windows PowerShell™ is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell™ helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.

The Microsoft Windows Script Host (originally called Windows Scripting Host, but renamed for the second release) 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.

mafu
  • 31,798
  • 42
  • 154
  • 247
  • 9
    +1. powershell gives you scripting capabilities backed by all the libraries from .NET, and more – leeeroy Apr 18 '10 at 17:56
6

Mafutrct has provided a very good response; if you are starting windows scripting then you should definitely begin with PowerShell. The built-in commands, PowerShell extensions and the ability to use the .NET runtime ensure that all your scripting requirements are met. I only wish for a better scripting language in PowerShell. If only it were Javascript :(.

I want to point out that WSH remains a viable scripting environment for windows. The reasons why I continue to use it are:

  • Javascript, being both functional and prototypal, allows complex scripts to be written simply and easily
  • Throw in WMI and almost everything windows related can be accomplished very easily. This is very useful for networking and system administration tasks
  • WSH scripts can be run with equal convenience on both window and console (i.e. invocation by wscript and cscript)
  • Writing a script is as easy as opening notepad, typing the script, saving it as a js (or .vbs, .wsh) file and double clicking the saved file
  • Although it no longer remains strictly a script, a .js file can be complied for the CLR using the .NET’s Javascript compiler: jsc.exe. Like PowerShell, this provides access to the entire .NET framework

Some of the scripts that I wrote in the last few weeks were:

  • Pulling data from MS SQL server, creating an Excel sheet and pushing the data into it, and mailing it to a client
  • Formatting, parsing and filtering thousands of lines of VOIP switch log files and vector scripts
  • Using Ajax to pull data from a remote server, calling a web-service and passing the data to it
  • I spook my co-workers when they use my laptop by remotely “speaking” to them via the speakers with a script using Microsoft’s Speech API. Here’s the sample code:

    var sapi = new ActiveXObject("SAPI.SpVoice");
    sapi.speak("hello world");
    
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Abbas
  • 6,720
  • 4
  • 35
  • 49
  • 1
    +1. I once completed all the assignments for a functional programming course by using WSH and Javascript on Windows. Edited in emacs! – Cheeso May 29 '13 at 05:36
  • Is the course available online? – Abbas Jun 04 '13 at 21:13
  • 1
    It was the CS-61A course from UC Berkeley. http://www.youtube.com/watch?v=zmYqShvVDh4 The video says it was from spring 2008, but the computer he uses make it look like spring 1988. From time to time, the instructor also makes claims like "You can't do [functional programming in C# or other modern languages". Quite wrong, since both C# and JavaScript have good functional characteristics, but I'll forgive him since he's stuck in 1988 and those languages haven't been invented yet. I did all the assignments using WSH + JavaScript. – Cheeso Jun 05 '13 at 00:13
2

You can use PHP without a full LAMP stack. Certainly you don't want the "L" if you are running on Windows!

I'd go with Strawberry Perl myself. While it doesn't have vast amounts of built in libraries, it does have the CPAN.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
2

I'm a fan of Python.

digitaldreamer
  • 52,552
  • 5
  • 33
  • 28
1

Perl, either a "real" win32 port (ActiveState or Strawberry Perl) or the Cygwin variant.

Christoffer
  • 12,712
  • 7
  • 37
  • 53
1

If (a) you've got experience in the LAMP world, and (b) you mostly want file and string manipulation, I recommend Lua and the Lua File System. It's a choice at the polar opposite of the design space:

  • Aggressively cross-platform. Lua itself (but not LFS) extends to handhelds, Palm Pilots, and so on.

  • Very simple, clean design. Incredibly high power-to-weight ratio.

Lua would be good if the problems you are solving are not Windows-specific and if there's any chance of your wanting similar solutions on other platforms.

Lua is also extraordinarily easy to learn (nothing is horrific), compiles with any C compiler, is backed by a great book, and has a one-stop native Windows implementation.

Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
0

Rebol is nice. The executable is a few hundred KB, requires no installation and can do GUI as well as console stuff. It can access files, URLs, execute programs, you name it. Syntax is truly minimal; Rebol has some of the neatest oneliners.. :)

0

Give Python a try. Its cross platform, has clear syntax, easy to install, lots of "batteries included" modules (if not there is repository Pypi, equivalent to Perl's CPAN).

ghostdog74
  • 327,991
  • 56
  • 259
  • 343