Display WSH & Engine properties

The following script demonstrates how to retrieve and display the properties of the WSH and the script engine.

'************************************************
' File: Properties.vbs (WSH sample in VBScript) 
' Author: (c) G. Born
' 
' Show the properties of the WScript object and
' the script engine within a dialog box.
'
' In no way shall the author be liable for any
' losses or damages resulting from the use of this
' program. Use AS-IS at your own risk.
'
' The code is the property of the author. You may
' use the code and modify it, as far as this header
' remains intact. Further updates and other samples
' may be found on my site:
' http://www.borncity.de
'************************************************

Option Explicit

Dim Message
Dim Title

' Show the properties of the WScript object
' we start with Host properties

Message = "WScript host properties" & vbCRLF & vbCRLF
Message = Message & "Application: " & WScript.Application & vbCRLF
Message = Message & "Name: " & WScript.Name & vbCRLF
Message = Message & "Version: " & WScript.Version & vbCRLF
Message = Message & "FullName: " & WScript.FullName & vbCRLF
Message = Message & "Path: " & WScript.Path & vbCRLF 

' Get the Interactive-Status
If (WScript.Interactive) Then
Message = Message & "Interactive: true" & vbCRLF 
Else
Message = Message & "Interactive: false" & vbCRLF 
End if

' Get script properties
Message = Message & vbCRLF 
Message = Message & "WScript script properties" & vbCRLF & vbCRLF
Message = Message & "ScriptFullName : " & WScript.ScriptFullName & vbCRLF
Message = Message & "ScriptName : " & WScript.ScriptName & vbCRLF

' get the version of the language engine
Message = Message & vbCRLF & "Script-Engine: " & CStr(ScriptEngine()) & vbCRLF
Message = Message & "Version: " & CStr(ScriptEngineMajorVersion()) 
Message = Message & "." + CStr(ScriptEngineMinorVersion()) + vbCRLF
Message = Message & "Build: " & CStr(ScriptEngineBuildVersion())

' init title
Title = "WSH sample " & WScript.ScriptName & " - by G. Born"

MsgBox Message, vbInformation + vbOKOnly, Title
' End

The script queries the properties (ScriptFullName, ScriptNameo etc.) of the WScript object and shows it within a dialog box. The script engine's properties may be retrieved using VBScript functions ScriptEngine(), ScriptEngineMajorVersion(), ScriptEngineMinorVersion(), ScriptEngineBuildVersion()). The code listing shon below implements the script in JScript.

//************************************************
// File:     Properties.js (WSH sample in JScript)   
// Author:   (c) G. Born
// 
// Show the properties of the WScript object and
// the script engine within a dialog box.
//
// In no way shall the author be liable for any
// losses or damages resulting from the use of this
// program. Use AS-IS at your own risk.
//
// The code is the property of the author. You may
// use the code and modify it, as far as this header
// remains intact. Further updates and other samples
// may be found on my site:
// http://www.borncity.de
//************************************************
//

var Message, Title, tmp;
var vbInformation = 64;    // a few constants
var vbOKOnly = 0;

// collect the properties of the WScript object
// read the Host properties

 Message = "WScript host properties \n\n";
 Message = Message + "Application: " + WScript.Application + "\n";
 Message = Message + "Name: " + WScript.Name + "\n";
 Message = Message + "Version: " + WScript.Version + "\n";
 Message = Message + "FullName: " + WScript.FullName + "\n";
 Message = Message + "Path: " + WScript.Path + "\n"; 

// get Interactive-status
 if (WScript.Interactive) 
  Message = Message + "Interactive: true" + "\n" 
 else
   Message = Message + "Interactive: false" + "\n";

// get the script properties
 Message = Message + "\n"; 
 Message = Message + "WScript script properties \n\n";
 Message = Message + "ScriptFullName : " + WScript.ScriptFullName + "\n";
 Message = Message + "ScriptName : " + WScript.ScriptName + "\n";

// get the script engine properties
 Message = Message + "\nScript-Engine : " + ScriptEngine() + "\n";
 Message = Message + "Version: " + ScriptEngineMajorVersion() + ".";
 Message = Message + ScriptEngineMinorVersion() + "\n";
 Message = Message + "Build: " + ScriptEngineBuildVersion();

// init title
 Title = "WSH sample  " + WScript.ScriptName + " - by G. Born";

 var objAdr = WScript.CreateObject("WScript.Shell");

 tmp = objAdr.Popup (Message, vbInformation + vbOKOnly, Title);

// End

Well, that's all. You can use this script to check the current properties of the WSH and the script engine. Additional information about this sample and more may be found in my WSH books, published by Microsoft Press.

Back

(c) G. Born