Tuesday, October 25, 2011

WiseScript Basics,its Uses ,Examples and Benefits

Hi i have already covered a basic discussion on vbscripting here on my blog.
I have below discussed a very informative and useful uses of wisescript in application packaging.if u have anyother uses and fundas do post openly.

what is wisescript?
WiseScript is a high-level scripting language that consolidates dozens or hundreds of lines of code into predefined script actions. WiseScript has been used for years to create application installations; however, this document focuses on its use as a tool for quickly creating utilities to automate system administration tasks.

Example: Adding, deleting, and moving files and directories; freeing disk space; and mapping network drives.

What Makes WiseScript Unique?
 Easy to learn WiseScript supports a point-and-click method of scripting.The script author is
prompted for the parameters needed by each script action, so a script can be
created and tested very quickly. The script is displayed in clear, English-like
statements. For those who need additional flexibility and control, WiseScript
provides advanced features (examples: IF and WHILE loops, UI dialogs).

No runtime needed WiseScripts are compiled into self-contained .EXEs that do not require an agent or
runtime files on the destination computer.

Compact size A WiseScript .EXE is small in size (about 100 KB). If a script uses any files that may
not be on the destination computer, it can compress those files into the .EXE.
(Example: A script that detects and removes spyware might temporarily install
Kill.exe on the destination computer while the script is running.)

Built-in rollback WiseScripts can be rolled back after they are executed on the destination computer.

User interface WiseScripts can incorporate any type of dialog to either inform the end user or
prompt for input.

Why Use wisescript?
  1. Use WiseScript to automate system administration tasks. Its easy-to-use, structured interface lets you create useful scripts in a fraction of the time it would take to write them in a free-form scripting language such as VBScript.
  2. WiseScript excels at retrieving information about a computer, prompting for input (example: passwords) if necessary, and taking action based on that information.
  3. A WiseScript collects and analyzes the data and takes action in real time.
Scenarios for Using WiseScript
• An end user reports that their default browser does not open when they click on an HTML file. You can create a simple WiseScript that reads the default browser from the registry, verifies that the default browser is installed, and either edits the registry key, installs the default browser, or both.
• You need to update a platform-dependent .DLL file on a collection of computers that are running different operating systems. Instead of creating a different Software Delivery task for each version of the file, you can create one Software Delivery task that runs a WiseScript. The WiseScript finds the version of Windows that is running on each computer and installs the correct .DLL file for that version.

Following are just a few of the tasks you can accomplish with WiseScript.
  • Move files and directories.
  • Modify a machine resource (example: registry key or .INI file).
  • Locate and delete a file and its directory (example: to remove a spyware program). See Locate and Delete a File and its Directory.
  • Free disk space by clearing the Temp directory, the Recycle Bin, or the Internet cache. See Clear the Temp Directory.
  • Find the current Windows version. See Find the Current Windows Version.
  • Find and report system information and take action depending on the results. See Find and Report System Information.
  • Map a network drive. See Map a Network Drive.
  • Assign license numbers from a text file.
About the Script Editor Interface
  1. All WiseScript products contain the Script Editor scripting environment. The script is compiled, along with files and other resources, into an .EXE. When the .EXE is launched, the script runs, executing the actions that are specified in the script.
  2. You create a WiseScript by adding actions to the script pane from a predefined list. When you add an action, a dialog appears that lets you enter the parameters for the action.

Adding an Action to a Script
In Script Editor, do any of the following:
  • From the Actions list in the left pane, drag an action onto a line in the Installation Script list in the right pane. The new action appears above the line that is highlighted when you drop the action.
  • Click in the script and double-click the action in the Actions list to place the new action above the line you clicked.
  • Click in the script and start typing the first few letters of the action name. As you type, the current line becomes a drop-down list with all the action names, and the action that most closely matches the letters you typed is the current item in the list. When the action you want is the current item in the list, press Enter.
  • When you add an action, a dialog appears that lets you set the parameters for the action unless it does not require parameters. When you add a Custom Dialog or Custom Billboard action, the appropriate editing environment opens.
  • Some actions come in pairs. (Example: When you add an If action, you must also add an End action at the end of the condition block.) Script Editor indents actions inside these pairs.

Sample Script
Clear the Temp Directory
Scenario: You need to clear the current user's Temp directory to free space for a new application.
In this example, the script reads the TEMP environment variable to get the path to the current user's Temp directory. Then it uses the Delete File(s) action to clear the directory.
You could use a similar script to empty the Recycle bin or clear the Internet cache.
An advantage of WiseScript's Delete File(s) action is that it attempts to delete every file in the directory individually. That way, when it encounters a read-only file (example: an Altiris agent XML file) or a file that is in use, it skips that file and proceeds to the next file. This is an improvement over the DOS delete *.* command, which stops when it encounters the first read-only file.
To create the sample script
  1. Open your WiseScript product.
  2. If a previous WiseScript opens, select File menu > New.
  3. If the New Installation File dialog appears, select Blank Script and click OK.
  4. In the Actions list on the left, double-click the Get Environment Variable action.
  5.  Complete the Get Environment Variable dialog as follows and then click OK. (Leave the defaults for any values that are not listed here.)
Env. Variable : Enter TEMP
Varriable Name : Enter TEMPFOLDERPATH
Drag the Delete File(s) action to the right pane (below the first action), complete its dialog as follows, and then click OK.
Pathname : Enter %TEMPFOLDERPATH %\*.*
Include Sub-Directories :Select this checkbox

Your Script Should look like this
Get Environment Variable TEMP into Variable TEMPFOLDERPATH
Delete File(s) %TEMPFOLDERPATH%\*.*

WiseScript Benefits
  • WiseScripts are totally self-contained and do not require a scripting engine on the destination computer.
  • WiseScripts can run on Windows 3.1, 95, 98, ME, NT, 2000, XP, and Windows Server 2003 with little or no modification.
  • WiseScripts can be run silently or, unlike a batch file, with end user interaction.
  • WiseScripts are small. The script engine is less than 100 KB.
  • WiseScript is easy to use.
  • You build WiseScripts by dragging and dropping actions and completing dialogs.
  • You do not have to declare variables before you use them.
  • Control and logic structures are very easy to build.
  • WiseScript is well known.
  • WiseScript is powerful.
  • In addition to the dozens of predefined actions, WiseScripts can call VBScripts and DLL functions, making it possible to use any Windows system call.
  • WiseScript is fast.
  • Because the WiseScript engine is written in C++, when you build a WiseScript, you are building a C++ program. A WiseScript executes faster than a VBScript that performs the same operation.
  • WiseScript is extensible.
  • You can streamline your scripting process by creating your own script actions for tasks that you perform frequently. To create a user-defined action, create a WiseScript .WSE (project file) and save it in the Actions subdirectory of the WiseScript product's installation directory. Your action will be available for use in future scripts.