Niyaz
Niyaz

Reputation: 54793

What tools and languages are available for windows shell scripting?

I want to know what are the options to do some scripting jobs in windows platform. I need functionality like file manipulations, registry editing etc. Can files be edited using scripting tools? What other functionality does windows scripting tools offer? Can everything that can be done using the Windows GUI be done using a scripting language?

Upvotes: 4

Views: 1942

Answers (12)

Zhi Yuan
Zhi Yuan

Reputation: 194

Powershell can do what you need.

file manipulations

This SO post answers how you can replace a string in your text file. Pasting it here for easy reference:

(Get-Content c:\temp\test.txt).replace('[MYID]', 'MyValue') | Set-Content c:\temp\test.txt

There are other things that you can do, such as copying files and folders. You can find out more on the Windows Powershell Documentation

registry editing

This can be easily done using Powershell. Here's a sample code from Microsoft Dev Blogs:

Set-ItemProperty -Path HKCU:\Software\hsg -Name newproperty -Value anewvalue

Upvotes: 0

Kaniabi
Kaniabi

Reputation: 530

I would recommend "Take Command" (JPSoft), which is more like "cmd.exe" than the PowerShell. We use here at ESSS for years.

Upvotes: 1

Josh Miller
Josh Miller

Reputation: 391

Scripting is a blast.

Personally I like to write some evil little batch files. You can find a command line program to do just about anything. I prefer Batch files mostly because they are portable from one machine to another with at most a zip with a few unix tools (SSED, GREP, GAWK). there is a commandline REG.Exe that can even do Registry changes and reads. You can parse output from commands with a "FOR /f" loop.

PowerShell does have more... err.. Power (2nd post I wrote that in, but I can't help it.)

If you want to look at windows automation check out AutoHotKey.

What are you trying to automate? That may help us narrow down what would be helpfull.

  • Josh

EDIT: for the record I typed that at the same time as @jameso If someone at work hadn't asked me a question, I may have posted before him. I did get a bit of a shiver at the similarity of the post though....

Upvotes: 0

James Ogden
James Ogden

Reputation: 852

Batch files are the most portable, but doing complicated things can get hard (very hard).

Powershell is incredibly - um - powerful, but the installed domain at the moment is only slightly more than those people who like using powershell and servers they administer. If you control the machines you're scripting on and can mandate that powershell is installed, powershell is the way to go. Otherwise, batch files are the best way.

Powershell lets you do anything which can be done, but some things will be harder than others :)

(Seriously, if you want to control a windows GUI app from a script, you're going to have a lot of pain unless the app supports scripting itself, or you want to start posting messages to dialog controls and screen scraping the dialog to check for success.)

Upvotes: 1

sparkes
sparkes

Reputation: 19503

Yesterday I could have repaired this for you ;)

What all are the tools/languages for windows shell scripting?

Would read better as

What tools and languages are available for windows shell scripting?

Upvotes: -1

cjanssen
cjanssen

Reputation: 156

I have cygwin installed, so I can run bash shell scripts for my automatization needs. Besides, when I need stuff running moreless natively on Windows, I use a combination of batch + jscript (runs on cmdline if you have Visual Studio.Net installed, just call "cscript XXX.js").

Upvotes: 0

Kibbee
Kibbee

Reputation: 66122

Powershell is nice, but it's an extra thing you have to install. Not standard in almost any windows installation. So, if it's just for your own use, then powershell should be fine. If you need the scripts to run on the computers of the general population, for instance, as part of a piece of software you are producing, it may not be the best option.

If you are ok with an extra thing you have to install, you might want to check out cygwin. This allows you to have a full Linux bash command line and all the associated tools at your disposal.

If you need something included in a default windows install. There's the windows command line (cmd.exe). Which has some functionality, but is very deficient compared to what's available in Linux. The other, probably worse problem, is that there isn't much out there in the way of documentation.

You might also be interested in VB Script (flame away). VB Script should work on almost any recent standard windows install, and is a lot more functional than the command line.

Upvotes: 0

cschol
cschol

Reputation: 13059

How about installing a windows version of Python, Perl or your favorite language? These should offer all the functionality you need.

Upvotes: 1

Gishu
Gishu

Reputation: 136613

CScript ? I remember seeing something like that.

Upvotes: 0

aku
aku

Reputation: 123974

Windows Scripting Languages

Also take a look at PowerShell

Upvotes: 0

Mark Ingram
Mark Ingram

Reputation: 73625

It might be worth looking at the prerelease of version 2.0. A lot of stuff has changed:

http://blogs.msdn.com/powershell/archive/2007/11/06/what-s-new-in-ctp-of-powershell-2-0.aspx

Upvotes: 1

David Sykes
David Sykes

Reputation: 7269

I think Windows PowerShell from Microsoft is the current favourite for this sort of thing.

Upvotes: 5

Related Questions