![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Executing secondary command in shell.run 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 System Specs![]() |
| | #2 (permalink) |
| | Re: Executing secondary command in shell.run Hi Han, Quote: > 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 > Quote: > with f > .writeline "dir" Quote: > end with |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Executing secondary command in shell.run 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 System Specs![]() |
| | #4 (permalink) |
| | Re: Executing secondary command in shell.run "Han" <hp4444@xxxxxx> wrote in message news:14E4F8BF-6E79-4A9E-AE02-65E84D0CBDBC@xxxxxx Quote: > 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 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 System Specs![]() |
| | #5 (permalink) |
| | Re: Executing secondary command in shell.run On Feb 13, 5:47*pm, "Paul Randall" <paul...@xxxxxx> wrote: Quote: > "Han" <hp4...@xxxxxx> wrote in message > > news:14E4F8BF-6E79-4A9E-AE02-65E84D0CBDBC@xxxxxx > > > Quote: > > Hello Quote: > > I want to run some commands consecutively with shell. See below, Quote: > > set shell=createObject("wscript.shell") > > set fso=createobject("scripting.filesystemobject") > > set f=fso.createTextfile("c:\put.txt", true) Quote: > > with f > > .writeline "dir" > > end with Quote: > > shell.run "%comspec% /k ""C:\program files\windows azure > > sdk\v1.0\bin\setenv.cmd"" -s:c:\put.txt", 1, true Quote: > > f.close Quote: > > 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". Quote: > > 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 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 System Specs![]() |
| | #6 (permalink) |
| | Re: Executing secondary command in shell.run Han wrote: Quote: > 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". 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 System Specs![]() |
| | #7 (permalink) |
| | Re: Executing secondary command in shell.run 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" <hp4444@xxxxxx> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù. news:14E4F8BF-6E79-4A9E-AE02-65E84D0CBDBC@xxxxxx Quote: > 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 System Specs![]() |
| | #8 (permalink) |
| | Re: Executing secondary command in shell.run 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" <hp4444@xxxxxx> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù. news:14E4F8BF-6E79-4A9E-AE02-65E84D0CBDBC@xxxxxx Quote: > 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 System Specs![]() |
| | #9 (permalink) |
| | Re: Executing secondary command in shell.run "Han" <hp4444@xxxxxx> wrote in message news:59D45276-1399-40F9-8B0F-651B6E7F4B36@xxxxxx Quote: > 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. 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 Quote: > "Han" <hp4444@xxxxxx> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù. > news:14E4F8BF-6E79-4A9E-AE02-65E84D0CBDBC@xxxxxx Quote: >> 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 System Specs![]() |
| | #10 (permalink) |
| | Re: Executing secondary command in shell.run 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@xxxxxx> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù. news:%23MRszTDkJHA.5124@xxxxxx Quote: > > "Han" <hp4444@xxxxxx> wrote in message > news:59D45276-1399-40F9-8B0F-651B6E7F4B36@xxxxxx Quote: >> 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 > > Quote: >> "Han" <hp4444@xxxxxx> ´ÔÀÌ ´ÙÀ½ ¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù. >> news:14E4F8BF-6E79-4A9E-AE02-65E84D0CBDBC@xxxxxx Quote: >>> 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 System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Shell Command | Tutorials | |||
| Trouble executing a command | PowerShell | |||
| Invoke-Expression executing a command with spaces | PowerShell | |||
| Executing Power Shell Scripts from Windows Shell | PowerShell | |||
| Executing a command like run [command] | PowerShell | |||