Hi Christopher,
> I created the following subroutine [...]
The subroutine has a couple of things missed and/or incorrect:
a) Sys.OleObject("Wscript.Shell") just instantiates an instance of script shell object. The Run method must be called to execute command passed as a parameter: Sys.OleObject("Wscript.Shell").Run(strCommandToExecute)
b) Single quote character ( ' ) starts single-line comment but not a string in VBScript. Double quote ( " ) must be used to define a string. Note, that if a string contains double quote inside it, such double quotes must be doubled: strString = "a string with a "" inside"
c) The second line in subroutine contains an attempt to concatenate several substrings, but the result is not assigned to any variable and thus is unusable. Should be something like this: strCommand = "osql - S " & strServerName & " -U "... Then the obtained command line should be passed as a parameter to the Shell.Run method: Sys.OleObject("Wscript.Shell").Run(strCommand)
d) Not all components of the command line you are trying to create can be evaluated as strings or variables. E.g.:
osql -S ' + 10.24.0.156 + ...
Here the 10.24.0.156 is neither a string nor a variable name and the script will eventually fail here.