WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

VBScript JScript in WinBatch


Just found that you can execute script code and even pass and return values from it, you do this passing an object that can be filled in vbs or js.

An example of this, I used a recordset to create the object variable

;MSScriptControl

adInteger=3
adFldRowID=256

osc=objectopen("MSScriptControl.ScriptControl.1")
osc.Language="JScript" ;"VBScript"

ors=objectopen("ADODB.Recordset")
ofds=ors.Fields()
ofds.append('v1',adInteger,4,adFldRowID)

;create object variable
ors.open()
ov1=ors.fields('v1')
ors.addnew()
ov1.value=2
message('before',ov1.value)

;pass it to JScript and change it
osc.addobject('ov1',ov1)
code="ov1.value=10;"
osc.ExecuteStatement(code)
message('after',ov1.value) ;new value in wb

objectclose(ov1)
objectclose(ofds)
ors.close()
objectclose(ors)
objectclose(osc)
http://www.microsoft.com/mind/0799/script/script.asp
Article ID:   W16708
File Created: 2005:02:18:12:21:56
Last Updated: 2005:02:18:12:21:56