Joined: 23 Nov 2009
|Posted: Mon Nov 23, 2009 9:32 pm Post subject: Command Line Arguments Problem
|There was a post from 2008 which mentioned this, but it appears to not be resolved yet. I can likely use the workaround indicated in that post, but this will cause me to have to rework a number of scripts. Is it possible to fix this so that it works?
In my script code, I use some command line arguments to change functionality of the application, like indicating a new config file, asking for usage syntax, and so on. However, the following lines fail:
if WScript.Arguments.Count > 0 then
WScript.Echo WScript.Arguments.Count&" Arguments Found"
for each arg in WScript.Arguments.Named
When it gets to the FOR loop, the following error is generated:
Microsoft VBScript runtime error
Error: Object not a collection
I am using the "Named" capability because I later pull out the value from the parameter. For example, one of my arguments is "/config:<configfile>", for which I can use this command to get the needed value:
WScript.Echo "Loading Alternate Configuration "&WScript.Arguments.Named.Item(arg)
I find that this does NOT work with the workaround, and it looks like I have to manually parse a bunch of strings instead of using thebuilt in features of WScript.
Looks like this may be a hole in the ScriptCryptor capabilties?