Assigning value to object nets "Expression continues past expected end"

Started by jtrask, January 27, 2016, 06:05:44 AM

Previous topic - Next topic


I am trying to assign a value to a task sequence variable.  I've created the Microsoft.SMS.TSEnvironment object, I've verified it's a valid object, but when I try to assign it a value, I get "Expression continues past expected end.  I'm using a Winbatch variables for both my task sequence variable name and value.  I thought that might be a problem, so I tried hardcoding the name and value.  No joy.  Why is this happening to me?  Is there a better way to verify that this object is legit?

#DefineFunction UDF_CreateTSVariable(vstrTSVariable,vstrValue)

; Set the program to goto the WBErrorHandler function if there is a problem.

; Resume DebugTrace (if it was already active)

vobjTSE = CreateObject("Microsoft.SMS.TSEnvironment")
vintObjectType = VarType(vobjTSE)
If (vintObjectType & 1536) != 1536 || vintObjectType == 0 Then
vobjTSE(vstrTSVariable) = vstrValue
If StriCmp(vobjTSE(vstrTSVariable),vstrValue) == 0 Then
End If
End If



You are attempting to use VB syntax in WinBatch.  WinBatch does not support magic-default-object-method syntax (something that some of the original VB implementers now admit was a mistake.)  So you need to figure out the name of the actual method being called when you attempt the assignment.  One way to do that is to use the WIL Type Viewer to examine the classes and objects involved.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade