The command being executed actually uses a couple of Environment variables,
which are expanded when passed to the command line (%comspec% and
%CLASSPATH% in particular). Due to the length of the expanded values of
these variables, the .Run method fails.
Limiting the length of these variables or changing the command line to be
shorter removes the error.
Is there a way to remove this limit, or is it purely a limitation of the
WScript object.
Thanks,
Craig
ph.
"Craig Schofield" <c...@connexus.net.au> wrote in message
news:3953428b$1...@news.internex.net.au...
if wscript.arguments.count > 0 then msgbox "ok":wscript.quit
set shell = createobject("wscript.shell")
scmd = wscript.fullname & " " _
& wscript.scriptfullname & " " & string(1024, "A")
cmd = left(scmd,516) ' works...
shell.run cmd,,true
cmd = left(scmd,517) ' fails...
shell.run cmd,,true
Oddly enough, enclosing the first 2 strings in quotes changes the threshold to 517.
scmd = """" & wscript.fullname & """ """ _
& wscript.scriptfullname & """ " & string(1024, "A")
cmd = left(scmd,517) ' works...
shell.run cmd,,true
cmd = left(scmd,518) ' fails...
shell.run cmd,,true
If you are executing a DOS program, the limit is smaller...
Q198429 - PRB: Executing a 16-Bit Process with a Large Command Line on NT
http://support.microsoft.com/support/kb/articles/Q198/4/29.ASP
--
Michael Harris
MVP Scripting
--
Bill James
Microsoft MVP·DTS
»Free Win9x VBScript Utilities«
»»New Address - Change your links!««
http://www.svvi.net/wgjames/vbspage/
Thanks for the pointers and suggestions. It looks like I will have to work
around this another way (I am considering writing the command line out to a
temporary batch file and executing it instead). The same command line works
fine from an NT command prompt, so the batch file approach should work.
The actual command line is the execution of a Java class, with a very long
CLASSPATH, hence the problems with length.
Thanks
Craig