• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Executing secondary command in shell.run

#1
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
 

My Computer

D

Dirk Stegemann

#2
Hi Han,


> 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
>
the scripts genearates a batch on zhe fly. So you should be able to simply add some commands.

> with f
> .writeline "dir"
..writeline "Some command"

> end with
Dirk
 

My Computer

D

Dirk Stegemann

#3
Sorry its early here in Germany ..


Correct Code here...

set shell=createObject("wscript.shell")
set fso=createobject("scripting.filesystemobject")
If fso.FileExists("C:\put.cmd") Then _
fso.deleteFile("C:\put.cmd")
set f=fso.createTextfile("c:\put.cmd", true)

with f
.writeline "dir c:"
.writeline "dir d:"
end With

shell.Run "%comspec% /k ""C:\put.cmd""", 1, true
 

My Computer

P

Paul Randall

#4
"Han" <[email protected]> wrote in message
news:[email protected]

> 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
On most WXP systems, there is a Help & Support item available from the start
button. Help & support typically links to ntcmds.chm for command-line
related queries. Unfortunately, on many computers such as those made by
Compaq/HP, they make it impossible to run ntcmds.chm separately from the
help and support center, so you can't use the CHM search facility to
directly find what you want. My Compaq's help & support center is
particularly unhelpful, in that when searching for "command shell overview",
I get only one hit: MS-DOS overview. We all know that there is no MS-DOS in
WXP.

Anyhow, on a systems where the manufacturer hasn't messed up ntcmds.chm, it
contains a section called 'Command Shell Overview", and it contains info on
running multiple commands.

The & character is the command separator.
Syntax:
command1 & command2

Of course, there may be times when you want to run command2 only if command1
runs successfully. For this, use two ampersands:
command1 && command2

There may also be times when you want to run command2 only if command 1
fails. For this, use two pipe characters:
command1 || command2

You might also want to group or nest multiple commands. For this use
parentheses:
(command1 & command2)

Parameters for the commands can be separated by semicolons or commas:
command1 parameter1;parameter2

HTH

-Paul Randall
 

My Computer

T
#5
On Feb 13, 5:47 pm, "Paul Randall" <[email protected]> wrote:

> "Han" <[email protected]> wrote in message
>
> news:[email protected]
>
>
>

> > 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
>
> On most WXP systems, there is a Help & Support item available from the start
> button.  Help & support typically links to ntcmds.chm for command-line
> related queries.  Unfortunately, on many computers such as those made by
> Compaq/HP, they make it impossible to run ntcmds.chm separately from the
> help and support center, so you can't use the CHM search facility to
> directly find what you want.  My Compaq's help & support center is
> particularly unhelpful, in that when searching for "command shell overview",
> I get only one hit: MS-DOS overview.  We all know that there is no MS-DOS in
> WXP.
>
> Anyhow, on a systems where the manufacturer hasn't messed up ntcmds.chm, it
> contains a section called 'Command Shell Overview", and it contains info on
> running multiple commands.
>
> The & character is the command separator.
> Syntax:
> command1 & command2
>
> Of course, there may be times when you want to run command2 only if command1
> runs successfully.  For this, use two ampersands:
> command1 && command2
>
> There may also be times when you want to run command2 only if command 1
> fails.  For this, use two pipe characters:
> command1 || command2
>
> You might also want to group or nest multiple commands.  For this use
> parentheses:
> (command1 & command2)
>
> Parameters for the commands can be separated by semicolons or commas:
> command1 parameter1;parameter2
>
> HTH
>
> -Paul Randall
Yes. Here's the demo code

option explicit
Dim strCmd1, strCmd2, strCmd3
Dim oShell

Set oShell = WScript.CreateObject ("WScript.shell")
strCmd1 = "dir /x"
strCmd2 = "dir /w"
strCmd3 = "pause"
oShell.Run "%comspec% /c" & strCmd1 & " && " & strCmd2 & " && " &
strCmd3,1,true
Set oShell = Nothing
 

My Computer

T

Todd Vargo

#6
Han wrote:

> 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".
Change put.txt to put.cmd, write all commands to it, then run put.cmd
instead.

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

with f
.writeline "@echo off"
.writeline "call ""C:\program files\windows azure
sdk\v1.0\bin\setenv.cmd"""
.writeline "dir"
.writeline "other commands"
end with

shell.run "c:\put.cmd", 1, true

f.close

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
 

My Computer

#7
Thank you very much Dirk, Paul, Tomy, and Todd Vargo.
I am trying one by one all of your recommandations.
They seem to help me a lot.

I will let you know the result. Currently Simple commands like "dir"
perfectly works. Not that the colud service command lines per se. I am happy
to see the legendary kindness of this NG persists.

"Han" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
news:[email protected]

> 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
 

My Computer

#8
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.


"Han" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
news:[email protected]

> 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
 

My Computer

A

Al Dunbar

#9
"Han" <[email protected]> wrote in message
news:[email protected]

> 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" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
> news:[email protected]

>> 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
>
 

My Computer

#10
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" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
news:%[email protected]

>
> "Han" <[email protected]> wrote in message
> news:[email protected]

>> 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" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
>> news:[email protected]

>>> 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
>>
>
>
 

My Computer

P

Paul Randall

#11
Hi, Han
I think you should look at the string you are trying to run. Either Echo it
or do a message box, like:
MsgBox "%comspec% /k" & _
strCmd1 & " && " & _
"cd .. && " & _
"cd .. && " & _
"cd .. && " & _
"cd .. && " & _
strCmd2 & " && " & _
strCmd3

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. Adding pauses may help show you what is going wrong.

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.

-Paul Randall

"Han" <[email protected]> wrote in message
news:[email protected]

> 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" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
> news:%[email protected]

>>
>> "Han" <[email protected]> wrote in message
>> news:[email protected]

>>> 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" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
>>> news:[email protected]
>>>> 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
>>>
>>
>>
>
 

My Computer

A

Al Dunbar

#12
"Han" <[email protected]> wrote in message
news:[email protected]

> 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"""
In actual fact, the above statement, in and of itself, did not cause the
error. The error resulted from forming an incorrect batch command.

> doesn't work with error message,
>
> "c:\Program is neither executable file nor batch file ..."
It is hard to know exactly what is what in your script, as the meaning of
<cspack AAA BBB\CCC.XXX> is not intuitive to me, and really quite ambiguous.
But given that cspack appears to be an executable, perhaps this might work:

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

What I cannot tell at this distance is what the parameters are that the
executable is expecting. The above suggests that it wants two parameters,
the first being the string "AAA" and the second an apparent relative file
path of "BBB\CCC.XXX". If the whole thing <AAA BBB\CCC.XXX> is a relative
file path, then perhaps this is what is needed:

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

But, again, we cannot tell you what is right if we do not know what the
actual files are and what the meaning of the arguments to cspack is.

I'd strongly recommend that you create the batch file manually, modify it
until it works, and then update your script to create an identical copy.

> 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.
You mention that "C:\BBB\CCC.XXX" is the worst case, but we do not know what
the best case is. I would have to guess that it would be the fully qualified
path to the file that you want cspack to process. What *is* that path? is it
on the C: drive?

I suspect my last suggestion above might work, but given that your batch
script changes the default folder, I would recommend that you not rely on
relative paths, but provide a completely qualified path to the file you want
cspack to process. The main benefit of relative paths is that they can be
entered more easily at the command prompt. When you are creating a vbscript
or batch script, it usually pays for the script to make sure that it
processes the files you want it to.

/Al

>
> "Al Dunbar" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
> news:%[email protected]

>>
>> "Han" <[email protected]> wrote in message
>> news:[email protected]

>>> 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" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
>>> news:[email protected]
>>>> 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
>>>
>>
>>
>
 

My Computer

#13
Thank you very much Paul and Al

I gave up and placed the stuff in non-space directory. I have a suspicion
than the beta Cloud computing component is implemented poorly.

Kind regards

"Paul Randall" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
news:%[email protected]

> Hi, Han
> I think you should look at the string you are trying to run. Either Echo
> it or do a message box, like:
> MsgBox "%comspec% /k" & _
> strCmd1 & " && " & _
> "cd .. && " & _
> "cd .. && " & _
> "cd .. && " & _
> "cd .. && " & _
> strCmd2 & " && " & _
> strCmd3
>
> 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. Adding pauses may help show you what is going wrong.
>
> 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.
>
> -Paul Randall
>
> "Han" <[email protected]> wrote in message
> news:[email protected]

>> 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" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
>> news:%[email protected]

>>>
>>> "Han" <[email protected]> wrote in message
>>> news:[email protected]
>>>> 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" <[email protected]> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù.
>>>> news:[email protected]
>>>>> 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
>>>>
>>>
>>>
>>
>
>
 

My Computer