Re: Executing secondary command in shell.run

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks Al Dunbar

Exactly. Representation instead of suppress.

Anyway. Your recommandation was my first try without success.

strCmd1 = """C:\program files\windows azure sdk\v1.0\bin\setenv.cmd"""

works as expected. But,

strCmd2 = """cspack AAA BBB\CCC.XXX"""

doesn't work with error message,

"c:\Program is neither executable file nor batch file ..."

The second command with double double quotation marks definitely affects the first commands here. I have no idea why they are related when the second has double double quotation marks.

On the other hand, when the second has no double double quotations error message is,

"no file named c:\BBB\CCC.XXX ..."

Which wrongly suppress the "AAA " part. I worry that can be caused from the program "cspack.exe", which is the worst case.


"Al Dunbar" <alandrub@xxxxxxxxxxx> 님이 다음 메시지를 작성했습니다. news:%23MRszTDkJHA.5124@xxxxxxxxxxxxxxxxxxxxxxx

"Han" <hp4444@xxxxxxxxxxxxxxxx> wrote in message news:59D45276-1399-40F9-8B0F-651B6E7F4B36@xxxxxxxxxxxxxxxx
Hello again

I think I am nearly at there except miner issue.

Set oShell = WScript.CreateObject ("WScript.shell")

strCmd1 = """C:\program files\windows azure sdk\v1.0\bin\setenv.cmd"""
strCmd2 = "cspack AAA.XXX"
strCmd3 = "pause"

oShell.Run "%comspec% /k" & _
strCmd1 & " && " & _
"cd .. && " & _
"cd .. && " & _
"cd .. && " & _
"cd .. && " & _
strCmd2 & " && " & _
strCmd3, 1, true

Above script works fine when I do "AAA.XXX". Works either with "AAA\BBB.XXX".
But doesn't work with "AAA BBB\CCC.XXX". i.e., when one of directoris has space.

How do you supress the spaces in such a situation? I tried everything I can imagine: every kind of single or double quotations.

You don't want to suppress the spaces because they are there in the path to the file in question. What you want to do is to represent them. You have already done that for the batch file, whose location you give as:

strCmd1 = """C:\program files\windows azure sdk\v1.0\bin\setenv.cmd"""

In a quoted literal string you represent a literal double quote character by including two double quote characters. Perhaps all you need do is to change this:

strCmd2 = "cspack AAA.XXX"

to this:

strCmd2 = """cspack AAA.XXX"""

/Al


"Han" <hp4444@xxxxxxxxxxxxxxxx> 님이 다음 메시지를 작성했습니다. news:14E4F8BF-6E79-4A9E-AE02-65E84D0CBDBC@xxxxxxxxxxxxxxxx
Hello

I want to run some commands consecutively with shell. See below,

set shell=createObject("wscript.shell")
set fso=createobject("scripting.filesystemobject")
set f=fso.createTextfile("c:\put.txt", true)

with f
.writeline "dir"
end with

shell.run "%comspec% /k ""C:\program files\windows azure sdk\v1.0\bin\setenv.cmd"" -s:c:\put.txt", 1, true

f.close

How do you run the second command "dir" here? Currently the first command setenv.cmd runs well. In real world scenario I will add some more commands after the "dir".

Thanks




.



Relevant Pages

  • Re: Executing secondary command in shell.run
    ... You should be able to open a cmd window, navigate to the folder in which strCmd1 is to be executed, paste in the 'run' string obtained above, and execute it. ... You may want to temporarily change strCmd1 and strCmd2 to a dir command to verify that your commands are being executed within the correct folders. ... The second command with double double quotation marks definitely affects the first commands here. ...
    (microsoft.public.scripting.vbscript)
  • Re: Executing secondary command in shell.run
    ... You may want to temporarily change strCmd1 and strCmd2 to a dir command to verify that your commands are being executed within the correct folders. ... The second command with double double quotation marks definitely affects the first commands here. ...
    (microsoft.public.scripting.vbscript)
  • Re: how to write sysrexx
    ... I now have a sysrexx question.... ... How do suppress the '/DI,L=Z' output after you issue the command. ... I used to work a lot of Netview and rexx inside Netview and we had IBM ... We use question mark as the command character for secondary JES2 ...
    (bit.listserv.ibm-main)
  • Re: very slow cursor in CMD window w/Text editor?
    ... There are too many spaces in the command you are typing. ... Native MS-DOS Commands and the Space Character ... string, but you must enclose them in quotation marks (for example, ...
    (microsoft.public.windowsxp.general)
  • Re: Server Application Error When Trying To Edit Graphs
    ... I went back in to Norton AntiVirus to enable the Office plug-in. ... the regsvr32 /u command again. ... "Ernie Wong" wrote: ... >> quotation marks and retype them. ...
    (microsoft.public.powerpoint)