Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How to set windows environment variables with SilkTest

How to set windows environment variables with SilkTest

SilkTest cannot directly set the windows environment variables, but it can be achieved by creating and executing a Visual Basic Script (VBS) file. These variables can be defined within a testcase or read from an external file. The example below demonstrates how to values can be set. If the variable does not exist then a new one is created and if it does exist then the variable is updated to the new value.

testcase setVariables() appstate none

STRING sJavaHome="H:\Program Files\Java\jdk1.5.0_11"

STRING sTomcatHome="D:\jakarta-tomcat-3.2.3"

//create a file handle

HFILE OutputFileHandle

//create a vbscript file that will insert the new variables or overwrite an existing one

OutputFileHandle=FileOpen("C:\EV.vbs", FM_WRITE)

FileWriteLine (OutputFileHandle, "Set WshShell = CreateObject(""WScript.Shell"")")

FileWriteLine (OutputFileHandle, "Set WshSystemEnv = WshShell.Environment(""SYSTEM"")")

FileWriteLine (OutputFileHandle, "WshSystemEnv(""JAVA_HOME"") = ""{sJavaHome}""")

FileWriteLine (OutputFileHandle, "WshSystemEnv(""TOMCAT_HOME"") = ""{sTomcatHome}""")

//close the file

FileClose (OutputFileHandle)

//execute script

SYS_Execute("wscript C:\EV.vbs")

//delete script

SYS_RemoveFile ("C:\EV.vbs")

Old KB# 23608

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:36
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.