0

Suppose I want to pass variables as my parameters, is it possible?

Example:

newva = 10 
obj = newobj.Run("%comspec% /c ruby E:\rubyfile.rb newva > D:\newdoc.txt", 1, true) 

Is this possible?

user692942
  • 16,398
  • 7
  • 76
  • 175
Vibha
  • 31
  • 6
  • It's the classic string concatenation issue, this question has been answered so many times before. – user692942 Aug 24 '16 at 10:15
  • 2 minutes and [found these](https://www.google.com/search?q=site%3Astackoverflow.com+vbscript+run+variable&oq=site%3Astackoverflow.com+vbscript+run+variable&aqs=chrome..69i57j69i58.10778j0j7&sourceid=chrome&ie=UTF-8), take your pick! – user692942 Aug 24 '16 at 10:31
  • 1
    Possible duplicate of [How to execute commands with variables as path in vbscript](http://stackoverflow.com/questions/29694523/how-to-execute-commands-with-variables-as-path-in-vbscript) – user692942 Aug 24 '16 at 10:35

1 Answers1

1

Concatenate the variable's value into the command line:

obj = newobj.Run("%comspec% /c ruby E:\rubyfile.rb " & newva & " > D:\newdoc.txt", 1, true) 

(Still using the bad variable names?)

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96