WshShell.Run command string length limit?
Author |
Message |
Joe Wagne #1 / 12
|
 WshShell.Run command string length limit?
Hi. I have a script that invokes a .exe with parameters. A lot of long parameters. The parms are variable, and if only a few are used, the invocation is fine. If there are a lot (I believe the limit is 255 chars), the command fails with 'Permission denied', which seems to have nothing directly to do with security. The .exe is being run with: retcode = WshShell.Run ("%comspec% /c " & strCommand, 0, TRUE) I've tried with and without the %comspec%. Also, it runs from the command line. I print out the invocation string to a log file, and if I paste that string on a command prompt, everything is fine. Any help would be appreciated. Thanks, Joe
|
Mon, 24 May 2004 09:03:57 GMT |
|
 |
Alex Angelopoulo #2 / 12
|
 WshShell.Run command string length limit?
Could you show us the command line as written in the script and the literal command line you type?
Quote: > Hi. > I have a script that invokes a .exe with parameters. A > lot of long parameters. The parms are variable, and if > only a few are used, the invocation is fine. If there are > a lot (I believe the limit is 255 chars), the command > fails with 'Permission denied', which seems to have > nothing directly to do with security. > The .exe is being run with: > retcode = WshShell.Run ("%comspec% /c " & strCommand, 0, > TRUE) > I've tried with and without the %comspec%. > Also, it runs from the command line. I print out the > invocation string to a log file, and if I paste that > string on a command prompt, everything is fine. > Any help would be appreciated. > Thanks, > Joe
|
Mon, 24 May 2004 10:00:29 GMT |
|
 |
Joe Wagne #3 / 12
|
 WshShell.Run command string length limit?
The command is (and you'll be sorry you asked): cmd /c C:\Winnt\System32 \IOScheduler.exe /M=E /J=VNIHotFix /R=A /A=cscript.exe /C=" La-la- la" /D=20021023 /T=23:15 /I=1 /U=administrator /P=vni /PARM S="<DELETEFILE>\"C:\Program Files\InstantOffice\Upgrade\HF20010529_0_1.CAB\",<DELETEFIL E>\"C:\Program Files\InstantOffice\Upgrade\HF20010529_0_10.CAB\",<DELETEFI LE>\"C:\Program Files\InstantOffice\Upgrade\HF20010529_0_12.CAB\"" /O="\"C: \Program Files\InstantOffice\ControlFiles\VniActionMgr.wsf\" /FILE=\ "C:\InetPub\ftproot\private\MSM\Backup\Trigger\Schedule Hot fixes.trg\"" Quote: >-----Original Message----- >Could you show us the command line as written in the
script and the literal Quote: >command line you type?
>> Hi. >> I have a script that invokes a .exe with parameters. A >> lot of long parameters. The parms are variable, and if >> only a few are used, the invocation is fine. If there are >> a lot (I believe the limit is 255 chars), the command >> fails with 'Permission denied', which seems to have >> nothing directly to do with security. >> The .exe is being run with: >> retcode = WshShell.Run ("%comspec% /c " & strCommand, 0, >> TRUE) >> I've tried with and without the %comspec%. >> Also, it runs from the command line. I print out the >> invocation string to a log file, and if I paste that >> string on a command prompt, everything is fine. >> Any help would be appreciated. >> Thanks, >> Joe >.
|
Mon, 24 May 2004 10:42:47 GMT |
|
 |
Alex Angelopoulo #4 / 12
|
 WshShell.Run command string length limit?
No, I'm glad I asked, because I *think* I see your problem ;). I'm not quite certain I know the "best" fix for it, but the issue is that the quote marks get severely mangled.... I'm not going to take a whack at that yet - if Michael Harris is on his "usual" schedule, he will probably be posting an answer for you right about now... ;). In lieu of that, a quick test to verify that the issue is with how VBScript is interpreting the name is to dump the command line into a CMD file, big.cmd, put it in a path with *no* spaces, and then use WshShell.Run ("%comspec% /c c:\whatever\big.cmd", 0, TRUE). Not *the* fix, but it will establish the cause for certain.
Quote: > The command is (and you'll be sorry you asked): > cmd /c C:\Winnt\System32 > \IOScheduler.exe /M=E /J=VNIHotFix /R=A /A=cscript.exe /C=" > La-la- > la" /D=20021023 /T=23:15 /I=1 /U=administrator /P=vni /PARM > S="<DELETEFILE>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_1.CAB\",<DELETEFIL > E>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_10.CAB\",<DELETEFI > LE>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_12.CAB\"" /O="\"C: > \Program > Files\InstantOffice\ControlFiles\VniActionMgr.wsf\" /FILE=\ > "C:\InetPub\ftproot\private\MSM\Backup\Trigger\Schedule > Hot fixes.trg\"" > >-----Original Message----- > >Could you show us the command line as written in the > script and the literal > >command line you type?
> >> Hi. > >> I have a script that invokes a .exe with parameters. A > >> lot of long parameters. The parms are variable, and if > >> only a few are used, the invocation is fine. If there > are > >> a lot (I believe the limit is 255 chars), the command > >> fails with 'Permission denied', which seems to have > >> nothing directly to do with security. > >> The .exe is being run with: > >> retcode = WshShell.Run ("%comspec% /c " & strCommand, 0, > >> TRUE) > >> I've tried with and without the %comspec%. > >> Also, it runs from the command line. I print out the > >> invocation string to a log file, and if I paste that > >> string on a command prompt, everything is fine. > >> Any help would be appreciated. > >> Thanks, > >> Joe > >.
|
Mon, 24 May 2004 11:18:34 GMT |
|
 |
Joe Wagne #5 / 12
|
 WshShell.Run command string length limit?
Thanks, Alex. I will try your experiment in the morning (when my eyes MIGHT be open). Regardless of the outcome, it is curious that, if some of the portions of the /parms 'parm' (the <Deletefile> constructs) are removed, it runs fine. Thanks for your time. Joe Quote: >-----Original Message----- >No, I'm glad I asked, because I *think* I see your problem ;). >I'm not quite certain I know the "best" fix for it, but the issue is that >the quote marks get severely mangled.... >I'm not going to take a whack at that yet - if Michael Harris is on his >"usual" schedule, he will probably be posting an answer for you right about >now... ;). >In lieu of that, a quick test to verify that the issue is with how VBScript >is interpreting the name is to dump the command line into a CMD file, >big.cmd, put it in a path with *no* spaces, and then use >WshShell.Run ("%comspec% /c c:\whatever\big.cmd", 0, TRUE). >Not *the* fix, but it will establish the cause for certain.
>> The command is (and you'll be sorry you asked): >> cmd /c C:\Winnt\System32
\IOScheduler.exe /M=E /J=VNIHotFix /R=A /A=cscript.exe /C=" Quote: >> La-la-
la" /D=20021023 /T=23:15 /I=1 /U=administrator /P=vni /PARM Quote: >> S="<DELETEFILE>\"C:\Program
Files\InstantOffice\Upgrade\HF20010529_0_1.CAB\",<DELETEFIL Quote: >> E>\"C:\Program
Files\InstantOffice\Upgrade\HF20010529_0_10.CAB\",<DELETEFI Quote: >> LE>\"C:\Program
Files\InstantOffice\Upgrade\HF20010529_0_12.CAB\"" /O="\"C: Quote: >> \Program
Files\InstantOffice\ControlFiles\VniActionMgr.wsf\" /FILE=\ Quote: >> "C:\InetPub\ftproot\private\MSM\Backup\Trigger\Schedule >> Hot fixes.trg\"" >> >-----Original Message----- >> >Could you show us the command line as written in the >> script and the literal >> >command line you type?
>> >> Hi. >> >> I have a script that invokes a .exe with parameters. A >> >> lot of long parameters. The parms are variable, and if >> >> only a few are used, the invocation is fine. If there >> are >> >> a lot (I believe the limit is 255 chars), the command >> >> fails with 'Permission denied', which seems to have >> >> nothing directly to do with security. >> >> The .exe is being run with: >> >> retcode = WshShell.Run ("%comspec% /c " & strCommand, 0, >> >> TRUE) >> >> I've tried with and without the %comspec%. >> >> Also, it runs from the command line. I print out the >> >> invocation string to a log file, and if I paste that >> >> string on a command prompt, everything is fine. >> >> Any help would be appreciated. >> >> Thanks, >> >> Joe >> >. >.
|
Mon, 24 May 2004 11:34:12 GMT |
|
 |
Alex Angelopoulo #6 / 12
|
 WshShell.Run command string length limit?
This looks a lot like a non-WSH error to me as I look at it. A couple of other (quicker?) things to help track down the issue... (1) Change the comspec statement to "%comspec% /k " and set the intWindowStyle flag from "0" to "1". This will enable you to see the command line as passed and the results of its execution: where it is, which command processor in particular was used, etc. You can also try "copy and paste" in there to coax it to work and see what else happens - script execution will of course continue once you close the processor window. (2) Verify what the value of comspec is on your system - I've seen it set to "command.com" on some NTish systems. This could be a problem. I think the crucial thing here is to see exactly what you are getting on the command line; right now, the /c switch and the "0" intWindowStyle flag are interfering with that...
Quote: > Thanks, Alex. > I will try your experiment in the morning (when my eyes > MIGHT be open). > Regardless of the outcome, it is curious that, if some of > the portions of the /parms 'parm' (the <Deletefile> > constructs) are removed, it runs fine. > Thanks for your time. > Joe > >-----Original Message----- > >No, I'm glad I asked, because I *think* I see your > problem ;). > >I'm not quite certain I know the "best" fix for it, but > the issue is that > >the quote marks get severely mangled.... > >I'm not going to take a whack at that yet - if Michael > Harris is on his > >"usual" schedule, he will probably be posting an answer > for you right about > >now... ;). > >In lieu of that, a quick test to verify that the issue is > with how VBScript > >is interpreting the name is to dump the command line into > a CMD file, > >big.cmd, put it in a path with *no* spaces, and then use > >WshShell.Run ("%comspec% /c c:\whatever\big.cmd", 0, > TRUE). > >Not *the* fix, but it will establish the cause for > certain.
> >> The command is (and you'll be sorry you asked): > >> cmd /c C:\Winnt\System32 > \IOScheduler.exe /M=E /J=VNIHotFix /R=A /A=cscript.exe /C=" > >> La-la- > la" /D=20021023 /T=23:15 /I=1 /U=administrator /P=vni /PARM > >> S="<DELETEFILE>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_1.CAB\",<DELETEFIL > >> E>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_10.CAB\",<DELETEFI > >> LE>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_12.CAB\"" /O="\"C: > >> \Program > Files\InstantOffice\ControlFiles\VniActionMgr.wsf\" /FILE=\ > >> "C:\InetPub\ftproot\private\MSM\Backup\Trigger\Schedule > >> Hot fixes.trg\"" > >> >-----Original Message----- > >> >Could you show us the command line as written in the > >> script and the literal > >> >command line you type?
> >> >> Hi. > >> >> I have a script that invokes a .exe with > parameters. A > >> >> lot of long parameters. The parms are variable, and > if > >> >> only a few are used, the invocation is fine. If > there > >> are > >> >> a lot (I believe the limit is 255 chars), the command > >> >> fails with 'Permission denied', which seems to have > >> >> nothing directly to do with security. > >> >> The .exe is being run with: > >> >> retcode = WshShell.Run ("%comspec% /c " & > strCommand, 0, > >> >> TRUE) > >> >> I've tried with and without the %comspec%. > >> >> Also, it runs from the command line. I print out the > >> >> invocation string to a log file, and if I paste that > >> >> string on a command prompt, everything is fine. > >> >> Any help would be appreciated. > >> >> Thanks, > >> >> Joe > >> >. > >.
|
Mon, 24 May 2004 18:00:47 GMT |
|
 |
Palotás Ann #7 / 12
|
 WshShell.Run command string length limit?
Hi Everybody, i am Anna from Hungary. I use the same code for my vbs. But when i am running it from whereever, the command.exe window begins to jump up and down. I can't kill this process from the Task Manager and I have to reboot my computer. What is wrong? Thanks in advance!
Quote:
> Hi. > I have a script that invokes a .exe with parameters. A > lot of long parameters. The parms are variable, and if > only a few are used, the invocation is fine. If there are > a lot (I believe the limit is 255 chars), the command > fails with 'Permission denied', which seems to have > nothing directly to do with security. > The .exe is being run with: > retcode = WshShell.Run ("%comspec% /c " & strCommand, 0, > TRUE) > I've tried with and without the %comspec%. > Also, it runs from the command line. I print out the > invocation string to a log file, and if I paste that > string on a command prompt, everything is fine. > Any help would be appreciated. > Thanks, > Joe
|
Tue, 25 May 2004 01:55:41 GMT |
|
 |
Alex Angelopoulo #8 / 12
|
 WshShell.Run command string length limit?
Anna - Could you post your code? Or - if it is extremely long - the relevant section of it. I am suggesting that because it sounds like you may have a recursion problem in there. A couple of things that may help diagnose the problem... (1) You should see wscript.exe or cscript.exe running in Task Manager as the host; killing that should solve the problem. (2) If your problem is continual cmd windows popping up, but the code works fine - you can make them invisible by using a command of form WshShell.Run (something, 0,TRUE) The "0" is for making it run hidden.
Quote: > Hi Everybody, > i am Anna from Hungary. I use the same code for my vbs. But when i am > running it from whereever, the command.exe window begins to jump up and > down. I can't kill this process from the Task Manager and I have to > reboot my computer. What is wrong? > Thanks in advance!
|
Tue, 25 May 2004 02:31:18 GMT |
|
 |
Joe Wagne #9 / 12
|
 WshShell.Run command string length limit?
I have verified that %comspec% = cmd.exe Interestingly enough, when I changed the invocation to /k, window style = 1, no window appeared. When I modified the parameters to remove 1 of the <Deletefile> actions (shortening the overall command), the invocation succeeded, and a command window was left after the command completed, but there was nothing on the command line for that window. I am about to give up on this, and write a COM object that will take the parameters and use CreateProcess that will spawn a process to run the command. Joe Quote: >-----Original Message----- >This looks a lot like a non-WSH error to me as I look at it. A couple of >other (quicker?) things to help track down the issue... >(1) Change the comspec statement to "%comspec% /k " and set the >intWindowStyle flag from "0" to "1". >This will enable you to see the command line as passed and the results of >its execution: where it is, which command processor in
particular was used, Quote: >etc. You can also try "copy and paste" in there to coax it to work and see >what else happens - script execution will of course
continue once you close Quote: >the processor window. >(2) Verify what the value of comspec is on your system - I've seen it set to >"command.com" on some NTish systems. This could be a problem. >I think the crucial thing here is to see exactly what you are getting on the >command line; right now, the /c switch and the "0"
intWindowStyle flag are Quote: >interfering with that...
>> Thanks, Alex. >> I will try your experiment in the morning (when my eyes >> MIGHT be open). >> Regardless of the outcome, it is curious that, if some of >> the portions of the /parms 'parm' (the <Deletefile> >> constructs) are removed, it runs fine. >> Thanks for your time. >> Joe >> >-----Original Message----- >> >No, I'm glad I asked, because I *think* I see your >> problem ;). >> >I'm not quite certain I know the "best" fix for it, but >> the issue is that >> >the quote marks get severely mangled.... >> >I'm not going to take a whack at that yet - if Michael >> Harris is on his >> >"usual" schedule, he will probably be posting an answer >> for you right about >> >now... ;). >> >In lieu of that, a quick test to verify that the issue is >> with how VBScript >> >is interpreting the name is to dump the command line into >> a CMD file, >> >big.cmd, put it in a path with *no* spaces, and then use >> >WshShell.Run ("%comspec% /c c:\whatever\big.cmd", 0, >> TRUE). >> >Not *the* fix, but it will establish the cause for >> certain.
>> >> The command is (and you'll be sorry you asked): >> >> cmd /c C:\Winnt\System32
\IOScheduler.exe /M=E /J=VNIHotFix /R=A /A=cscript.exe /C=" Quote: >> >> La-la-
la" /D=20021023 /T=23:15 /I=1 /U=administrator /P=vni /PARM Quote: >> >> S="<DELETEFILE>\"C:\Program
Files\InstantOffice\Upgrade\HF20010529_0_1.CAB\",<DELETEFIL Quote: >> >> E>\"C:\Program
Files\InstantOffice\Upgrade\HF20010529_0_10.CAB\",<DELETEFI Quote: >> >> LE>\"C:\Program
Files\InstantOffice\Upgrade\HF20010529_0_12.CAB\"" /O="\"C: Quote: >> >> \Program
Files\InstantOffice\ControlFiles\VniActionMgr.wsf\" /FILE=\ Quote: >> "C:\InetPub\ftproot\private\MSM\Backup\Trigger\Schedule >> >> Hot fixes.trg\"" >> >> >-----Original Message----- >> >> >Could you show us the command line as written in the >> >> script and the literal >> >> >command line you type?
>> >> >> Hi. >> >> >> I have a script that invokes a .exe with >> parameters. A >> >> >> lot of long parameters. The parms are variable, and >> if >> >> >> only a few are used, the invocation is fine. If >> there >> >> are >> >> >> a lot (I believe the limit is 255 chars), the command >> >> >> fails with 'Permission denied', which seems to have >> >> >> nothing directly to do with security. >> >> >> The .exe is being run with: >> >> >> retcode = WshShell.Run ("%comspec% /c " & >> strCommand, 0, >> >> >> TRUE) >> >> >> I've tried with and without the %comspec%. >> >> >> Also, it runs from the command line. I print out the >> >> >> invocation string to a log file, and if I paste that >> >> >> string on a command prompt, everything is fine. >> >> >> Any help would be appreciated. >> >> >> Thanks, >> >> >> Joe >> >> >. >> >. >.
|
Tue, 25 May 2004 04:04:02 GMT |
|
 |
Alex Angelopoulo #10 / 12
|
 WshShell.Run command string length limit?
That sounds very strange. One final thing you may try is the shell.exec method as a test; you can then capture StdOut and StdErr in the script itself.
Quote: > I have verified that %comspec% = cmd.exe > Interestingly enough, when I changed the invocation to /k, > window style = 1, no window appeared. > When I modified the parameters to remove 1 of the > <Deletefile> actions (shortening the overall command), the > invocation succeeded, and a command window was left after > the command completed, but there was nothing on the > command line for that window. > I am about to give up on this, and write a COM object that > will take the parameters and use CreateProcess that will > spawn a process to run the command. > Joe > >-----Original Message----- > >This looks a lot like a non-WSH error to me as I look at > it. A couple of > >other (quicker?) things to help track down the issue... > >(1) Change the comspec statement to "%comspec% /k " and > set the > >intWindowStyle flag from "0" to "1". > >This will enable you to see the command line as passed > and the results of > >its execution: where it is, which command processor in > particular was used, > >etc. You can also try "copy and paste" in there to coax > it to work and see > >what else happens - script execution will of course > continue once you close > >the processor window. > >(2) Verify what the value of comspec is on your system - > I've seen it set to > >"command.com" on some NTish systems. This could be a > problem. > >I think the crucial thing here is to see exactly what you > are getting on the > >command line; right now, the /c switch and the "0" > intWindowStyle flag are > >interfering with that...
> >> Thanks, Alex. > >> I will try your experiment in the morning (when my eyes > >> MIGHT be open). > >> Regardless of the outcome, it is curious that, if some > of > >> the portions of the /parms 'parm' (the <Deletefile> > >> constructs) are removed, it runs fine. > >> Thanks for your time. > >> Joe > >> >-----Original Message----- > >> >No, I'm glad I asked, because I *think* I see your > >> problem ;). > >> >I'm not quite certain I know the "best" fix for it, but > >> the issue is that > >> >the quote marks get severely mangled.... > >> >I'm not going to take a whack at that yet - if Michael > >> Harris is on his > >> >"usual" schedule, he will probably be posting an answer > >> for you right about > >> >now... ;). > >> >In lieu of that, a quick test to verify that the issue > is > >> with how VBScript > >> >is interpreting the name is to dump the command line > into > >> a CMD file, > >> >big.cmd, put it in a path with *no* spaces, and then > use > >> >WshShell.Run ("%comspec% /c c:\whatever\big.cmd", 0, > >> TRUE). > >> >Not *the* fix, but it will establish the cause for > >> certain.
> >> >> The command is (and you'll be sorry you asked): > >> >> cmd /c C:\Winnt\System32 > \IOScheduler.exe /M=E /J=VNIHotFix /R=A /A=cscript.exe /C=" > >> >> La-la- > la" /D=20021023 /T=23:15 /I=1 /U=administrator /P=vni /PARM > >> >> S="<DELETEFILE>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_1.CAB\",<DELETEFIL > >> >> E>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_10.CAB\",<DELETEFI > >> >> LE>\"C:\Program > Files\InstantOffice\Upgrade\HF20010529_0_12.CAB\"" /O="\"C: > >> >> \Program > Files\InstantOffice\ControlFiles\VniActionMgr.wsf\" /FILE=\ > >> "C:\InetPub\ftproot\private\MSM\Backup\Trigger\Schedule > >> >> Hot fixes.trg\"" > >> >> >-----Original Message----- > >> >> >Could you show us the command line as written in the > >> >> script and the literal > >> >> >command line you type?
> >> >> >> Hi. > >> >> >> I have a script that invokes a .exe with > >> parameters. A > >> >> >> lot of long parameters. The parms are variable, > and > >> if > >> >> >> only a few are used, the invocation is fine. If > >> there > >> >> are > >> >> >> a lot (I believe the limit is 255 chars), the > command > >> >> >> fails with 'Permission denied', which seems to > have > >> >> >> nothing directly to do with security. > >> >> >> The .exe is being run with: > >> >> >> retcode = WshShell.Run ("%comspec% /c " & > >> strCommand, 0, > >> >> >> TRUE) > >> >> >> I've tried with and without the %comspec%. > >> >> >> Also, it runs from the command line. I print out > the > >> >> >> invocation string to a log file, and if I paste > that > >> >> >> string on a command prompt, everything is fine. > >> >> >> Any help would be appreciated. > >> >> >> Thanks, > >> >> >> Joe > >> >> >. > >> >. > >.
|
Tue, 25 May 2004 04:24:16 GMT |
|
 |
Alex Angelopoulo #11 / 12
|
 WshShell.Run command string length limit?
Sorry, I hit send too soon. Here's an example of a VBScript sub I wrote which uses the Exec method to grab info from a process. Sub ExternalCMDCall(cmdline,strOut) set objExCmd = objShell.Exec(cmdline) strOut = objExCmd.StdOut.ReadAll Call Cleanup(strOut) End Sub I haven't used StdErr before, but I assume you can do something like this: strErr = objExCmd.StdErr.ReadAll and then echo back strOut and StrErr to get the output. Note that you *have* to be using cscript as the host to make use of these methods.
|
Tue, 25 May 2004 04:31:15 GMT |
|
 |
MVP #12 / 12
|
 WshShell.Run command string length limit?
FWIW, I experimented with WshShell.Exec while 5.6 was in beta to see just how large a command line it would take and it's ridiculously large. The test involved sending a single string argument of varying lengths. It worked fine up to string length of 32K-1 (yes, a string of 32,767 characters ;-). -- Michael Harris Microsoft.MVP.Scripting
Quote: > Sorry, I hit send too soon. > Here's an example of a VBScript sub I wrote which uses the Exec method to > grab info from a process. > Sub ExternalCMDCall(cmdline,strOut) > set objExCmd = objShell.Exec(cmdline) > strOut = objExCmd.StdOut.ReadAll > Call Cleanup(strOut) > End Sub > I haven't used StdErr before, but I assume you can do something like this: > strErr = objExCmd.StdErr.ReadAll > and then echo back strOut and StrErr to get the output. > Note that you *have* to be using cscript as the host to make use of these > methods.
|
Tue, 25 May 2004 09:04:56 GMT |
|
|
|