I'm trying to minimize the number of vbs files that I have for a number of imacro te开发者_JS百科sting I have. I'm fairly new to scripting and I'm still learning to make my code simpler.
Summary:
I have one imacros (iim file) of which the URL parameter is being supplied by a vbs file. I have 47 parameters ie. http://www.domain.com/page.jsp?{{url}}
The value of {{url}} is supplied by different vbs file with the same code but different parameters using iimset, ie.
var=iim1.iimset("url","link1"}}
This part is the only difference in all of my 47 vbs file. Ref - http://wiki.imacros.net/iimSet%28%29
all of these vbscript is being called by batch file with interval of 15 minutes each.
My question is:
- Can I pass the variable from batch file to vbscript?
- Or is there another easy way to do this?
I've been looking for answers for two days already. I hope you guys can lend a hand. Thank you so much again.
I don't know anything about imacros, but vbs scripts (via Windows Script Host) support parameters, which can be accessed by the Arguments
property of the WScript
object. You can have named or anonymous parameters. Eg a batch file that runs a VBScript file
REM run test.vbs with a named parameter and an anonymous parameter
cscript test.vbs /a:"a value" "another value"
PAUSE
and the VBScript itself:
option explicit
dim param1: param1 = WScript.Arguments.Named("a")
dim param2: param2 = WScript.Arguments.UnNamed(0)
WScript.Echo "param1: " & param1 & " param2: " & param2
will output
param1: a value param2: another value
see http://msdn.microsoft.com/en-us/library/z2b05k8s(v=vs.85).aspx
精彩评论