Heaventools

   English English  Deutsch Deutsch

home  products  resource tuner console  sample scripts library

How To Write Scripts

You can create a script with any text editor as long as you save your script with a RTC-compatible script extension (.rts). The most commonly available text editor is already installed on your computer — Notepad.

RTCThere are no particular requirements except that every script must contain the Main procedure, enclosed by Sub and End Sub statements. Inside the Main procedure there can be any number of statements.

Here's a guide on writing RTC scripts:

1 Save the file with a suitable name and ensure that the file extension is ".rts" to make it RTC-compatible (e.g., "myscript.rts").

2 Ensure that each script contains the Main procedure, enclosed by Sub and End Sub statements. The Main procedure is where the main code execution will take place. You can include multiple statements within the Main procedure.

3 Avoid line breaks within the code. VBScript, which is the default scripting language used by Resource Tuner Console, requires that the entire command and its parameters for each operation be on a single line.

4 Use single quotation marks to add comments in the script. Simply add a single quotation mark at the beginning of a line to indicate that it is a comment. The script engine will ignore all comments, allowing you to include explanatory or descriptive text within your script.

Once you have written your script, you can execute it using Resource Tuner Console to perform resource editing tasks based on your requirements.

Example:

Sub Main
  '-------- Place your script here --------
    ... 
...
...
'----------------------------------------
end Sub


Command Line Setting Override

The Command Line Setting Override feature allows you to set or override command-line settings directly within the script body. This is particularly helpful when you want to modify settings for a specific script or run different scripts with distinct settings without the need for separate batch files.

To create a command line setting override, follow these steps:

1 Add the desired #define attributes in the script body. These attributes specify the options you want to override. For example, if you want to silence the output stream, you can use the #define Silent On attribute.

1 Ensure that the #define attributes are separated from the script code by an empty line. This separation is necessary for the proper interpretation of the override settings.

By incorporating the #define attributes within the script body and separating them from the code with an empty line, you can easily override specific command-line settings for a particular script. This approach allows for convenient customization and ensures that the desired settings are applied only to the designated script, without affecting other scripts or requiring separate batch files.

The following table details all the overrides:

Option Syntax Description

Scripting Language

#define ScriptLang LangName Specifies the scripting
language.
Logging On/Off #define Logging [on|off] Instructs whether or not to create a log file.
LogName #define LogName Name Specifies the name of a log file (including the full path)
Append Log On/Off #define AppendLog [on|off] Instructs whether or not to append a log to the existing log file.
Silent On/Off #define Silent [on|off] Instructs whether or not be silent.

Scripting Language

Allows you to specify the scripting language of your choice. RTC supports any active scripting language that is installed and supported by Windows Script Host. While VBScript is the default scripting language for RTC, you have the flexibility to use other languages as well.

The syntax is as following:

#define ScriptLang LangName

where the LangName argument can have the following values:

vb VBScript Default scripting language
js JavaScript Default scripting language
perl Perl Should be installed on the system
python Python Should be installed on the system
rexx Rexx Should be installed on the system
tcl Tcl Should be installed on the system
lua Lua Should be installed on the system

Here are a few key points regarding scripting language options:

1 Default Scripting Language: The default scripting language in Resource Tuner Console is VBScript. VBScript and JavaScript are components included with Edge/Internet Explorer and are typically pre-installed on Windows systems.

2 Supported Scripting Languages: Resource Tuner Console can work with any active scripting language that is compatible with Windows Script Host. This means you can choose from various scripting languages such as Perl, Python, Rexx, TCL, and Lua.

3 Language Dependencies: If you opt to use a scripting language other than VBScript or JavaScript, it is important to ensure that the corresponding language modules or interpreters are already installed on your system. These modules provide the necessary runtime environment for executing scripts written in that specific language.

By specifying the desired scripting language, Resource Tuner Console enables you to use the scripting language with which you are most comfortable and productive. Whether it's the default VBScript, JavaScript, or another supported language, RTC offers the flexibility to accommodate your scripting preferences and requirements.

Log Name

Allows you to specify the name of a log file, including the full path if necessary. When enabled, this feature creates a log file that provides a detailed record of all events and actions performed during the editing process.

The syntax is as following:

#define Logname Name

where Name is the name of a log file. Don't forget to use quotes if the log name contains spaces.

For example, if you want to name your log file "MyLog.txt" and save it in the "C:\Logs" directory, you would use the following directive:

#define Logname "C:\Logs\MyLog.txt"

By incorporating the Log Name directive in your script, Resource Tuner Console will generate a log file with the specified name, documenting the sequence of events and actions taken during the editing process. This log file serves as a valuable resource for reviewing and troubleshooting operations performed by Resource Tuner Console.


Example of Commmand Line Setting Overrides:
  
'---------script body starts here----------

#define ScriptLang vb
#define Silent off
#define Logging on
#define Appendlog off
#define Logname "c:\test\test_log.txt"

'--------------------------------------------------------------------------------

' The above attributes must be separated with an empty line from the script code.

'--------------------------------------------------------------------------------

Sub Main
  '-------- Place your script here --------
    ... 
...
...
'----------------------------------------
end Sub


 Documentation on WSH and VBScript

A familiarity with VBScript helps with reading and writing the scripts. The documentation on VBScript and Windows Scripting in general can currently be found at:

Learn.microsoft.com
VBScript Language Reference

Download a zipped copy of the last published script documentation on WSH and VBScript from Microsoft for ready reference, it is available as a handy .CHM file. Make sure to install it and spend some time browsing through it. Then when you need it maybe you will not have much of a struggle finding what you need.

 

The Complete Illustrated Step-by-Step Guide To Using Scripts

 Download Resource Tuner Console and learn how it can make you more productive.