views:

129

answers:

1

Hello all,

What I am trying to do is have some sort of script run in windows (ideally .cmd file/batch file) when double clicked it should create a short-cut menu in the start menu and set a path in the windows registry (i think thats what it is called) so that next time, for example, all I have to is get the variable JAVA_HOME to get the path I need.

What I need help in this is just examples on how to do these, what tutorials I should look at or even what key terms to search in Google (seriously) as I am very new to windows programming and what's used for what etc.

Thanks all

+5  A: 

If you want to target all versions of Windows, your best choice is writing a MS-DOS Batch file (.bat). Here's a good tutorial that I've used in the past.

If you are targeting modern versions of Windows (Windows XP SP2/2003/Vista/7) you should definitely take a look at Windows PowerShell, which is the new standard automation engine for the Windows platform.
PowerShell is a separate download for Windows XP SP2, Windows Server 2003 and Windows Vista, while it is included in Windows Server 2008 and Windows 7.

About Windows PowerShell

PowerShell is built on top of the .NET Framework and consists of a runtime environment, a scripting language and an interactive console.

Here are some of its key features that I find most valuable:

  • All processing is done using CLR objects, instead of text as in traditional shells
  • It is possible to interact directly with the classes in the .NET Framework
  • It is possible to run commands written in any .NET language and distributed as DLLs (called Cmdlets)
  • Great collection of built-in commands to accomplish most administrative tasks
  • The scripting language's syntax is C-style (curly braces...)
  • The runtime can be hosted inside any managed process as an ad-hoc automation engine

This isn't of course a complete list of all the features in PowerShell. If you are interested, I recommend you to look into it. Here is a good place to start.

Enrico Campidoglio
+1 for PowerShell, although a link to a good tutorial would be nice.
musicfreak
Thank you for your reply. I am guessing what can be done on bat files can be done on the PowerShell? Or can one do more?
Abs
PowerShell can do a lot more than most shells, especially the MS-DOS emulator ;-) I updated my answer with some more details about PowerShell.
Enrico Campidoglio
A nice compromise is VBScript, which is already present on Windows 2000 and later. It's more robust than batch scripting, but more available than Powershell.
Jason R. Coombs
@Jason: You're absolutely right. I forgot about the Windows Script Host (WSH), which supports scripting in VBScript and JScript and allows to interact with COM/ActiveX objects. In that regard it is the predecessor of PowerShell.
Enrico Campidoglio