Below is a sample Run Script vbscript that creates a new project with a single Run Script (jscript) step, which retrieves the computer name with jscript, which the VBScript "uses". This is derived from the Script.bld sample.
Code:
jscript = "var cname = new ActiveXObject('WScript.Network').ComputerName;" & vbcrlf & _
"Application.Macros(vbldMacroProject).Add('CNAME', cname);"
val = RunJScript(jscript, "CNAME")
msgbox val
Function RunJScript(script, macroName)
Dim objApp, objBld, objStep
' create VisBuildPro app and build objects and connect
Set objBld = CreateObject("VisBuildSvr6.Builder")
Set objApp = CreateObject("VisBuildSvr6.Application")
objBld.Initialize objApp
' create an empty LOGFILE macro to disable logging of the
' temporary project
objApp.Project.Macros.Add "LOGFILE", ""
' create a project that creates a file
' add a write File step and set its properties
Set objStep = objApp.Project.Steps(vbldStepMain).Add("Run Script")
objStep.Name = "Run JScript"
objStep.Indent = 0
objStep.Property("Language") = "JScript"
objStep.Property("Script") = script
' build the dynamic project
if objBld.SyncBuild() = vbldBuildCompDone Then
RunJScript = objApp.Project.Macros(macroName).Value
Else
builder.LogMessage "Error in script"
step.BuildStatus = vbdStepStatFailed
End If
End Function